Solr - Remove collapsed groups from final result - solr

I'm using Apache Solr 7.1 and using FieldCollapse feature to group documents based on a field.
Sample Document:
{id: "ASDF1234",count: 10, event: "Create"}
Sample request: http://localhost:8983/solr/brandNewComp000/select?fq={!collapse%20field=id%20sort=count%20desc}&q=*:*&rows=30
Grouping is working fine. But in the final response I want to exclude few documents based on a condition on event field. That is I want to exclude few collapsed documents in the final response.
Is it possible to do that?
Note: If I add another filter query (fq) or query (q) to filter on 'event' field then that filtering 'happens before grouping' which is NOT the behavior I am looking for. I want to exclude documents after collapsing is done. Please guide me.

I don't understand why you don't want to filter out before the grouping. That is a reasonable approach. Otherwise, you may have to filter by yourself in your application.

Related

Amazon like refined filtering in solr

We need to implement drill down search like Amazon.
If any supplier is selected then,
currently it disabled rest of suppliers as solr facet only returns that selected filter.
query: supplier:supplierId
Though above query retuns multiple Screen Color/Screen Size, but on further selection, only the selected element is returned per filter section.
Any help to make it work like Amazon.com 's refined filtering will be much appreciated.
To provide multi-select faceting, you need to tag the filter involved so that you can exclude it when faceting on the corresponding field. This can be achieved using both the tag and ex local parameters.
Solr Ref Guide - Tagging and Excluding Filters :
To implement a multi-select facet for a given field, a GUI may want to still
display the other field values and their associated counts, as if
the corresponding filter constraint had not yet been applied.
To return counts for the field values that are currently not selected,
tag filters that directly constrain the field, and exclude those
filters when faceting on it.
For example, for a query that would originally look like :
q=mainquery&fq=supplier:supplierId&facet=true&facet.field=supplier
You would do the following :
q=mainquery&fq={!tag=sup}supplier:supplierId&facet=true&facet.field={!ex=sup}supplier

Solr search statistics in category scale

I need to implement further functionality picture of it is attached below. I've already built an application based on Solr search.
In a few words about this functionality: drop down will contain similar search phrases within concrete category and number of items found.
In what way to make Solr collect such data and somehow receive it?
Yes, you can do that in Solr using Facets, which allow grouping results. The default behaviour of facets is to return the group name and the number of items found. You do that by adding these 2 items you your query string facet=true, facet.field=category.
An example query in your case will be
http://localhost:8983/solr/NAME_OF_YOUR_INDEX/select/?wt=json&indent=on&q=ipo&fl=category,name&facet=true&facet.field=category
Take a look at the tutorial for more details.
This is roughly equivalent to doing this in SQL:
SELECT category, COUNT(*) FROM items WHERE text LIKE "%ipo%" GROUP BY category;

Select multiple values of same facet using IBM WCS v7 and Apache Solr

We use IBM WCS v7, with embeded Apache Solr. Solr is used as a search engine for our e-commerce based application.
As per a recent requirement, we want to use multi select facet functionality, where the user can check multiple facet attributes, and the corresponding values will be OR'ed to the search result.
Ex- I wish to check Color:RED, Color:BLUE and Color:BLACK in my default Search Results, so that each attribute value will be OR'ed in the resulting search results display.
We use the out-of-the-box SearchDisplayCmd, for our Search functionality, where the field "metaData=" takes care of history of the facets applied, and "facet=" takes care of applying a facet field. For the query param "metaData", it encodes the multiple facets into base64 encoding. It uses a special de-limiter to AND the different facet fields,and restrict the search results.
brand:"POLO" color:"RED" shape:"Oval"
I want to know, if there exists any such de-limiter or any alternatives by using which, I can perform an OR operation, on different values of the same facet attribute, and use "metaData" parameter to maintain a history of the applied facets.
Any help on the same front is highly appreciated. Any other approaches, on applying multiple values of the same facet attribute are also welcome.
Great Thanks in advance.
Regards,
Jitendriya Dash
I recently worked on this: Select multiple values of same facet
I was able to get it also.
Try to find where it hits the tag. The expression builder I used comes OOB. getCatalogNavigationView. Make sure you use the appropriate searchProfile.
Pass the facet param in this way.
<c:forEach var="facetSelect" value="paramValues.facet">
<wcf:param name="facet" value="facetSelect>
</c:forEach
But by this method you will not be able to select values from any other attributes. If someone knows how to select values from the same facet or different facet, pls share.
Update SELECTION column of FACET table to 1 to mark the facetable attribute as multi selectable.
In WCS7+, for enabling multi select facet functionality go to FACET table and set 'SELECTION' column value to 1 instead of 0.
If an attribute is to be made multi select facet, you can make the changes from CMC. Go to the attribute dictionary select the attribute and in facetable properties, check 'Allow multiple facet value'.

Difference between Solr Facet Fields and Filter Queries

I am using SolrMeter to test Apache Solr search engine. The difference between Facet fields and Filter queries is not clear to me. SolrMeter tutorial lists this as an exapmle of Facet fields :
content
category
fileExtension
and this as an example of Filter queries :
category:animal
category:vegetable
categoty:vegetable price:[0 TO 10]
categoty:vegetable price:[10 TO *]
I am having a hard time wrapping my head around it. Could somebody explain by example? Can I use SolrMeter without specifying either facets or filters?
Facet fields are used to get statistics about the returned documents - specifically, for each value of that field, how many returned documents have that value for that field. So for example, if you have 10 products matching a query for "soft rug" if you facet on "origin," you might get 6 documents for "Oklahoma" and 4 for "Texas." The facet field query will give you the numbers 6 and 4.
Filter queries on the other hand are used to filter the returned results by adding another constraint. The thing to remember is that the query when used in filtering results doesn't affect the scoring or relevancy of the documents. So for example, you might search your index for a product, but you only want to return results constrained by a geographic area or something.
A facet is an field (type) of the document, so category is the field. As Ansari said, facets are used to get statistics and provide grouping capabilities. You could apply grouping on the category field to show everything vegetable as one group.
Edit: The parts about searching inside of a specific field are wrong. It will not search inside of the field only. It should be 'adding a constraint to the search' instead.
Performing a filter query of category:vegetable will search for vegetable in the category field and no other fields of the document. It is used to search just specific fields rather than every field. Sometimes you know that the term you want only is in one field so you can search just that one field.

Solr Spell Check result based filter query

I implemented Solr SpellCheck Component based on the document from http://wiki.apache.org/solr/SpellCheckComponent , it works good. But i am trying to filter the spell check result based on some other filter. Consider the following schema
product_name
product_text
product_category
product_spell -> copy string from product_name and product_text . And tokenized using white space analyzer
For the above schema, i am trying to filter the spell check result based on provided category. I tried querying like http://127.0.0.1:8080/solr/colr1/myspellcheck/?q=product_category:160%20appl&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true . Spellcheck results does not consider the product_category:160
Is it because the dictionary was build for all the categories? If so is it a good idea to create the dictionary for every category?
Is it not possible to have another filter condition in spellcheck component?
I am using solr 3.5
I previously understood from the SOLR-2010 issue that filtering through the fq parameter should be possible using collation, but it isn't, I think I misunderstood.
In fact, the SpellCheckComponent has most likely a separate index, except for the DirectoSolrSpellChecker implementation. It means the field you select is indexed in a different index, which contains only the information about that specific field you chose to make spelling corrections.
If you're curious, you can also have a look how that additional index looks like using luke, since it's of course a lucene index. Unfortunately filtering using other fields isn't an option there, simply because there is only one field there, the one you use to make spelling corrections.

Resources