I have a document in a lucene which, say, models a shop.
The document has a number of terms which specify the items the shop has. Now I want to associate a price with every item in the document without having to create extra fields for each item. I want to be able to sort on these prices and filter on these prices.
How can I achieve this functionality? I had thought of payloads for sorting, but not sure how to do the filtering part?
Related
I'm creating a flutter app which needs shopping basket functionality. I'm using Firestore to save the contents of user's shopping baskets but do not know how best to do this.
At the moment, I have a collection called 'baskets' which contains documents (with the users id as the reference).
Within these documents, should I have a field which is a dictionary/map with key = productID and value = quantity, or should I just create a field for every product that the user adds to their basket?
Or is there a better way altogether (still using Firestore).
You are on the right track. Creating a root collection called baskets, under which each user has its own document based on the user's unique UID is good. Now, inside each of the user's documents, you can add a sub-collection called cartItems, where you will hold a document per product.
For each product then you can add its name, price, and amount and other descriptive product fields. That way instead of having multiple documents of the same product, just add a document per product, and a field called amount which you increment as users add more items of that same product.
You will be able to calculate how much is the total cost of their cart by pulling all documents, adding up all the amount fields of products times their individual prices, etc.
You can increment / decrement the amount of products, or altogether remove the product from their basket by removing the product document.
The main collection baskets should look like this:
While your cartItems subcollection could look like this:
Good luck!
I need to create a new collection on my Solr 6.1.0 cluster where every row is a content and every content can belong to one or many categories, which are specified in a multivalued field categories.
In my web app the user can search by categories, and if wanted it can even group results by category. If it wants to order by category, what about the contents which belong to more than one category?
In this case, the search results page should show the same content more times in different categories. I don't want the web application to filter and order results because in this case, it should ask Solr for every row (I know this is not advised for bad performance), so is there a way to let Solr make this? For example, repeating the same content in two categories if a flag is enabled or if I am asking Solr to sort by category?
Until now I bypassed the problem cloning one record for every category and specifying the category ID in a single int field. But this is not optimized, because in this case my index is much bigger than it could be, and every content metadata a part of category is just the same for every content, and because of this I would like to have 1 content = 1 Solr record.
I am having a list of products. I have added to the google appengine search API index with each product being each document. User can search for products. So far everything is good.
Now I want the user to be able to sort by price of the product ascending or descending. If i have fixed price for each product, I could simply build separate indexes and put the documents inside them. But unfortunately, the prices are dynamic. The product price can change 3-4 times a day. I have more than 200,000 products.
Since rewriting the document each time the price changes is bad, I have a ndb datastore model which has the documentID and price as the entity attributes.
Is there any way to sort the search api results, based on the price in the ndb model. Alternate design solutions are also welcome.
We want to build a faceted search within our application. For example, if we have quantity field whose values range from 1-20 for 2000 records. We need to allow the user to filter by those values.
To, accomplish this we are planning to extract the quantity field sort, eliminate duplicate records and build a widget on the left hand side of the screen, so the user can select what we need.
Is there a way to get this faceted criteria from Solr or any better way to implement it.
This is what Solr calls a Facet, and is enabled using facet=true
&facet=true&facet.field=quantity
.. will give you a facet entry back in the response, containing a count for each unique value in the quantity field. When the user clicks a quantity link, apply a fq for that particular quantity value, such as fq=quantity:4.
You can use facet.sort to determine if the facet should be sorted by hits (most popular quantity first) or alphabetical.
Multi-Select Facets and Local Params might also be useful, if you want to still show the original counts while allowing the user to drill down into the selection when applying an fq with the selected quantity as a criteria.
I'am trying to find an efficient approach or algorithm to help me address the problem described below.
Let's say we have a database containing a very large collection of products. Each product has a large set of attributes, although these attributes could be shared among product. In additon, product are organized into multiple hierarchical categories.
An example: Home -> Kitchen -> dishwashers -> GE Electric Dishwasher Model blablabla.
I would like to present to a user browsing our products a list of possible filters he could use. To illustrate it think about Amazon product filters on the side of the page: If products have a "price" attribute, then they show a slider with the lower price and the highest price as extremities. If the attribute is "brand", they have a list of all the brand for all children of a selected category. Categories and attributes are two separate concepts in our design.
My problem is all computing these filters takes time because we have a very large collection of products with dozens of attributes. Is there a particular way to perform this filtering? I was thinking about computing all filters at each level before hand but since a user may apply the filter at a higher category and keep navigating down into more specific categories, the latter categories would need to be recomputed/updated anyway.
What we have tried: for each product in a selected category we compute the intersection of attributes and create filters based on it. results are not cached since filters propagate from parents to children categories when applied.
PS: the database I am using is SQL server 2012. Let me know if more information is needed to better answer/understand my question. Also if you think of more appropriate tags for this question, please feel free to update it.