I have a category and products table. In view, I need to list the data in the following way
Category1 title
id product name price (in a table)
Pagination numbers (I will pass the category id here)
Category2 title
id product name price
Pagination numbers
etc
etc
How can I do the pagination for this ? On first pagination click, other paginations should not be changed. Categories are dynamic.
I don't think there is an easy direct cakephp way of doing this. But you can do it. You need is to customize the links so the pass on another variable identifying the parameter and then you have to parse it and do the pagination.
I google it and find the same solution but with a step by step tutorial :D
How to have multiple paginators
Here they use the model name to identify it but you will have to put something like model1, model2, etc so you identify which one is it, or simply numbers or words you need.
Related
I have a big table of data and have created some Select components to show all of the unique options in that column.
If my data was about supermarkets, I want to be able to see all in America. So America is selected and it works well so far. Then I want to see all Supermarkets that stock Bananas in America, so from the location column America is selected, and in the fruits, column bananas are selected. Still working well.
If I want to see all Supermarkets in America that stock Bananas or Apples, we get problems.
How can I apply the AND to separate columns, but the OR to filters of the same column?
Instead of trying to use 2 different link operators, you can achieve what you need using the right combination of filter operator and link operator.
There's no way to do that using the default filter panel. You'll have to create and manually pass a filter model to the grid.
Steps to get it done:
Use the isAnyOf filter operator.
Provide the filter value as an array of values.
Use the AND link operator.
Manually pass the custom filter model created to the grid.
Note:
Your UI should contain some sort of dropdowns for each column with multiple checkboxes for all the choices that can be added to the filter value array.
So in your case, a dropdown for countries, and another for fruits.
The filter Model should look something like this:
I am experimenting with Solr Facets. I imported my DB
pseudo:
item colorName colorID
ball red 1
plate red 1
table blue 2
Now, when I display the facet on the site, I instinctually want to have both colorName and colorID in my json, however the Solr Fusion interface and all the documents I have read the last several hours tell me I can only do either {Colorname, count} or {colorID, count} where I actually want { colorID,ColorName, count}. I dont have a real reason actually but coming from the old times, I couldn't feel comfortable with just a name or id and not both...
Facets are meant to be simple key => value pairs, with the key being your facet.field and the value being the number of documents that fall under that facet. The idea is to be able to give users a broad overview of various categories, along with the number of items available in that category. From there, you can use filter queries to drill down further into the data.
Your best bet in your example is to facet on multiple fields. For example:
/select?q=field_name%3APIN&rows=0&wt=json&indent=true&facet=true&facet.field=unique&facet.field=manufacturer_id
And then filter on whatever combination you need.
So I am pretty new to Apache Solr and have a situation I do now know how to handle. I am from an OO programming background so first let me explain the object relationships:
Take an object called Movie that has two text fields, title and description. A movie can be associated with tags by a user. These tags are particular to the user, and are not visible to other users.
So an example Movie could have something like this:
"Movie Title", "Description of the Movie"
User1Tags: "tag1", "tag2"
User2Tags: "action", "somethingElse"
I need to design a schema/solr query so that when user1 is searching for movies, if they type "action", the movie above will not show up. This is because user2 has associated "action" with "Movie Title", not user1.
Things I have considered:
1) Filter queries - these do not seem to work as once the index per movie is built, I do not see how to avoid having all the user tags be tied to the movie's index.
2) A separate core for movie to tag associations and just doing two queries per search. I know I can do it this way, but making another core seems excessive to me.
Are there other options I am missing? Or is there a way to implement 1? Or is the simplest option just option 2 and that's how people who know what they are doing with Solr would do it?
How many users?
If not many, then you can have dynamic fields tag_user1, tag_user2 and modify the eDismax field list to match or not match against it, e.g. by using field name alias.
The other option is to prefix the values with the userid. So tags field would have: user1_tag1, user1_tag2, user2_action, user2_somethingElse. Then, you need a custom filter in the query chain that will prefix your search tokens with the user of the request and so only prefixed values would match.
We have a website on which you can search through a large amount of products from different shops. Say we have 5 products per result page and the 10 best matches for a search have all the same score. 8 of the products are of one shop (A), and the two others by two other shops (B,C).
What we often get is (letter indicating a product of this shop)
A
A
A
A
A
---- second result page ----
A
B
A
C
A
but what we want to get is something like this:
A
C
B
A
A
---- second result page ----
A
A
A
A
A
Writing function query seems to be one option
http://www.solrtutorial.com/custom-solr-functionquery.html
What is the best way to achieve this?
You could group the results by shop using Field Collapsing and display the result either as a group or flattened list (depending on how you want it).
Another trick that I've seen in use to help the users see results from multiple group is to use Facets. You could have a sidebar (or something similar) that does two things:
By default it lets the user know that there are other filter criteria (ex. shops) in the result. This helps a lot when the result is paginated.
With facets being present, it is upto the user to choose whatever criteria she/he wishes to apply, thus relieving you of implementing heavy scenario based logic.
Read more about faceting here.
Edit:
If you have to use custom sort logic, you could write it down using Functions and use it in the sort when querying Solr. Here is the reference from the docs.
Solr returns each facet as a collection of name/count pairs (wrapped in a FacetField). In my faceted search app I would use these as follows.
Audi (2)
Honda (5)
Mitsubishi (6)
Mercedes Benz (8)
Now I would like to turn this into a list of links. I could create URLs like
http://www.example.com/category=Mercedes%20Benz
That would work, but I would much rather have
http://www.example.com/category=4
That is, I would like to use the database ID of the categories/brands instead of their names.
Can I somehow link fields in Solr, so that I can link the category name to the category ID and have them both returned from my query? Or should I use a multivalued field and store the category name and id together?
Your advice is most welcome :)
I have an idea. You can define a new field which joins category id and category name together. Just like express below.
1_Audi, 2_Honda, 3_Mitsubishi ,4_Mercedes Benz
Faceting on the new field will get result like this,
1_Audi(2)
2_Honda(3)
3_Mitsubishi(4)
4_Mercedes Benz(5)
You can split them laterly to get both category id and name. Name for disply while id for link.
You can check for Solr pivot as well which will return the Category Name and the Category Id as parent child facet hierarchy which in you case will always be one to one match.