I am not sure if this can be done with solr. But this is what I am doing for an online store search functionality. The main search box is a dismax parser for multiple fields :
qf: description^1.0 color^1.0 name^1.0 size^1.0
Equal weight across multiple fields for now. Further I create a facet on some of these fields
ex: color, size. The client has a request that when they search using a particular keyword and it matches any of the faceted fields the filter appear selected in the front end. So if the user searches for 'red' The color facet for red should appear selected.
Since solr is searching across multiple fields I don't think this is possible or is it?
It is not about Solr. First, This requirement is flawed at user experience level. Traditionally facets (also known as guided navigators) are used to filter search results. Just having "red" across multiple fields does not mean all the products appeared are colr "red" .
When you have "red" selected in Co filter you are visually telling user that all products in search results are "red". If that is not the case do not do it.
It that is the case, then ideal situation is, when the user enters "red" , you should first check user input against colr facets (preferably against cacheed list) and then add that color as filter to query as fq=colr:red parameter so that it is "true" filter and is part of your search query. This can be done against all known displayed facets (colr,size etc.) very quickly and activate them automatically if there is a match. Used right, that would actually make a cool feature.
Related
I have created a custom index that stores multiple extra fields that I use to filter by. Say for example I am storing some facets to select Kite colors. Some kites have one color, others have multiple.
Kite A color: dark blue red orange deep red
Kite B color: blue
Where kite A colors are dark blue, red, orange, and deep red.
A query as such
+color:blue
would return both kite a and kite b, even though kite A color is deep blue but not blue. Only kite B should be returned.
My question is this - and its probably been hard for me to find and answer because I dont know the proper terminology, but how should I be storing the values in lucene so that I can separate the values (delimiter?). In addition, how do I phrase the query so that if I search for
color:red it does not return rows that have the value color:"deep red"? And if I were to search for color:(deep red) it wont return rows that have "red" but not "deep red"
Take a look at search index analyzer types: search results depend on the analyzer type + search settings of the object (page type, custom table, etc.).
I think color field is marked tokenized in search settings, that's why it returns results that match individual tokens (subsets) of the field's value. If tokenized disabled, the search only returns items if the full value of the field exactly matches the search expression.
One suggestion here. Are you asking visitor to type in the color (I assume not), or you have a filter list that they can check to filter?
If its a filter list, then you may want to consider use "dark_blue" as the value and "dark blue" as the display. Both for content entry and filter. That way, the filter would be color:dark_blue.
Then your index for this can use "Start width" as the analyzer type, so when search "dark blue", it's looking at "dark_blue" as value, which "blue" will not return. Then, when search "blue", "dark_blue" will not show because it dosen't start with "blue..."
I want to filter an index by an exact value of an attribute. I wonder what possibilities Algolia offers for that.
Querying an index always results in a search for substrings, that means a search term abc will always match any object which attribute values contain abc. What I want to achieve is a search for abc that finds only abc as a value of an attribute (in this case I have specific attributes to search in).
One possibility I came up with was tagging, which doesn't seem to be the best way to think of.
Edit
I think I could also use facet filters. I thought about the different pros and cons and can't come up with arguments that places either one position above the other.
You're right with your edit that facet filters would be the way to go on this one. You'll get the exact match you're looking for and won't have to create a new attribute of _tags to use the tag filter.
I use the edismax query parser to handle user queries against our Solr 4.10.3 server.
I configured the q.op parameter to AND and completely disabled the mm parameter in order to hit only 100% matches.
When users search for multiple terms in a single field everything works fine.
For example the query food:(beer cola pizza) returns only those documents that contains all of the terms beer, cola and pizza in the field food which is the expected behaviour.
But when users search in multiple fields Solr seems to forget about the q.op configuration and behaves as if the parameter was set to OR.
For example the query food:(beer cola pizza) AND color:(green yellow blue) returns all those documents that contains one of the terms beer, cola OR pizza in the field food and those that contains one of the terms green, yellow OR blue in the field color which isn't the expected behaviour.
A workaround is to explicitely prepare each term with the + operator just like this: food:(+beer +cola +pizza) AND color:(+green +yellow +blue).
But I need to add this operator in our java-webapplication which is kind of a 'hard code' feature. When users decide to configure the q.op operator back to OR the hard coded + would cause problems I think.
Is there a way to reach the expected search results by configuration?
Is it possible to apply filters/facets automatically based on search term?
For example, If there are two facets called "Category" and "Material" ,and If user searches for the term "plastic water bottles" where bottle is one of the category
(Catergory=bottle) and plastic is one of the material facet(Material = Plastic).
I am looking for the option to enable/force search engine to filter based on category=bottle and material=plastic automatically when it has matching terms in the query.
Please help.
This is not possible. It is possible to trigger oneboxes, keymatches and related queries based on keywords.
So I need to search a database of boxes. Each box can contain multiple items. Each box has a general description and each item has a description along with some descriptor/value pairs (ie, size:large). I want to be able to search this database using a similar set of information- I'm looking for a box like x, holding a, b, and c items. Return the box that contains the most similar items.
However, I'm confused about how I should go about indexing this data in Lucene. I know that I can index multiple values to a single field by overriding the getPositionIncrement() method of the analyzer, but how do I link descriptors to a specific item? For example, I may have 2 items in my box:
Item 1
description: pair of shoes
color: blue
Item 2
description: Jacket
color: red
and I search for
Item A
description: pair of shoes
color: red
Item B
description: Jacket
color: blue
to my knowledge, it will return the box with item 1 and 2 as a match. But I want the color to only apply to that specific item, and I need to be able to search a box to match multiple items simultaneously to find the most similar box.
The reason I'm using Lucene is because this is a regular search job that occurs on a regular basis, but it isn't live, so a search server like Solr is not needed because searches only occur in narrow windows.
In this case you need to store relation between parent document (box) and child documents (items). Fortunately there is BlockJoinQuery for such purposes. This article describes it in details for Lucene 3.x or you can use ToParentBlockJoinQuery which is available for Lucene 4.x