solr faceted search - how do I specify multiple fields on the Solr Query UI? - solr

I'm a newbie to solr and tying my hands at solr.
Can some one here please explain how to specify multiple facet fields for a given search.
I'm using the Solr Admin UI/ query ink and it allows me to specify only one field.
I would however like to facet on multiple fields like region industry stock-exchange etc on my company search.
I have gone through the solr wiki and relevant doc links like the one below
http://docs.lucidworks.com/display/solr/Query+Screen
but none of them seem to explain how to specify multiple fields.
I want to build something like the usual Amazon/Walmart etc search ui that provides multiple facets and counts when trying to search for a product on my planned cmpany search page.

You can query multiple facet fields. Just write with the syntax:
.../select?q=&facet=true&facet.field=<field1>&facet.field=<field2>

When you execute the search in the Solr Query UI, it will show the actual url that is being sent to Solr above the results pane. Click on that url and it will open a new window in your browser to that url. From there you can add additional parameters to the url to get facteing on multiple fields, by adding additional &facet.field=<your field> entries.
Please see the Solr Faceting Parameters reference for more details and other options.

You are looking for json.facet
It's available from solr 5(some advanced features are available from solr 6).
Basically that means you can insert your facet search parameters via json to the url.
It looks like this(live example):
&facet=true&json.facet={"filed1":{"type":"terms","field":"filed1","limit":2000},"filed2":{"type":"terms","field":"filed2","limit":2000}}
There is also a shorter version:
&facet=true&json.facet={"field1":{"terms":"field1"},"field2":{"terms":"field2"}}
You can find more information here

For facet queries, its not done till 4.3. Resolved for versions 4.4/5.0

The Solr Admin UI allows you to specify multiple facets fields i.e. a csv of fields in the facet.field parameter. You need to check the facet checkbox and then you will get more options.
If you are querying Solr using a link then the link should look like - facet=true&facet.field=field1&facet.field=field2.

Related

SOLR Query with multible fields to search for

i've build a query in solr that looks like this:
https://local.solr.com/solr/select?omitHeader=true&wt=json&json.nl=flat&q=*:*&fq=xtitleLow_stringS:*1002*+OR+xartnumLow_stringS:*1002*
I want to search in solr with the query "1002" for results. I didn't work it out how to search both fields with the normal query so i used the filter query.
But i can't boost the results so im kind of lost on this point. How to build this as a query so i can boost some of the fields?
thank you.
You can try with the edismax handler provided by Solr. This allows to use list of fields to query. It has option to give separate weights for each of the field for scoring them differently.
defType=edismax&q=1002&qf=xtitleLow_stringS^20 xartnumLow_stringS
The above query will search for 1002 in each of the mentioned fields.
It will be also adding a boost of 20x to any hits in the xtitleLow_stringS field.
Please find the documentation link here for more details

Apache Solr use entire string for search within collection

I have managed to create a dataset using Apache Solr. I have also managed to make queries, such as in this example:
content:(test1 OR test2) OR title: test2
I would now like to search the dataset using an entire string, in similar fashion to searching on google. Is the correct way to approach this to keep using or tags on the title and content for each word within the query, or is there a better way to achieve this ? (I am not looking for exact matches, just the most relevant ones)
You can use dismax or edismax for your approach and can pass the phrases if you have with the boosting.
The DisMax query parser is designed to process simple phrases (without
complex syntax) entered by users and to search for individual terms
across several fields using different weighting (boosts) based on the
significance of each field. Additional options enable users to
influence the score based on rules specific to each use case
(independent of user input).
The detailed parameters are found on the solr page at Solr Dismax

Migrating SOLR fq to Elasticsearch

I am currently migrating a SOLR app to Elasticsearch and have become stuck on a particular query. The ElasticSearch documentation is rather vague on how to achieve my desired result.
Currently I am trying to convert tagged "fq's" (filter queries) from SOLR into Elasticsearch. I need to be able to return from Elasticsearch facets (now known as aggregations) based on my query and filters but also show aggregations for other options in a search
Although this sounds complicated it is achieved in SOLR simply by adding an "fq" parameter and tagging the filter as follows:
q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&facet=on&facet.field={!ex=dt}doctype
From the main SOLR help docs this will filter on "doctype:pdf" but also include counts for other doc types in the facet output - again this works fine for me, I am simply trying to recreate this in Elasticsearch.
So far I have tried a "post_filter" which does the job until I wish to apply anymore than one filter (again something SOLR handles with no problems). You can see an example of how this works and how I want to achieve it at:
https://www.jobsinhealthcare.co.uk/search?latitude=&longitude=&title=&location=&radius=5&type=&salary=0&frequency=year&since=&jobtype=&keywords=&company=&sort=Most+recent&filter[contract_type_estr][33d5667c]=Temporary&filter[job_type_estr][5d370027]=Part+time&filter[job_type_estr][4b45bd05]=Full+time
IN the filters/facets on the Right of the results you can select multiple "contract type" and/or "job type" and/or "location" and still be shown the facet counts for unselected queries/filters. Please note that Hourly Salary, Annual Salary and Date Added do NOT have this functionality - this is by design.
Any pointers as to how I should be structuring my query would be greatly apprreciated.
I think what you need is global aggregation (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html). Inside top level aggregation you should use filter aggregation (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html) as a sub-aggretation to filter only "status:public".

how to grouping result by domain in solr?

I have crawled many sites with nutch. I'm using Solr 3.4 to browse the results but I want to group the results by their domain. For example, if I search for "tabnak", the first result only contains "http://tabnak.ir" and does not show the other results from that domain (like google does).
I want to ignore results such as:
http://tabnak.ir/en/news/1020/title
http://tabnak.ir/fa/allnews
...
How can I create query for solr with group, group.field and ...?
Thanks
You should create a separate indexed field (for example named 'domain' in this case) and should make sure you separate the domain from the url when SOLR indexes your data.
Then you have to apply grouping of field collapsing to your search results. See: http://wiki.apache.org/solr/FieldCollapsing

How do I retrieve all applicable facet fields for a Solr search

I'm trying to use Solr for faceted-seaarch on a website.
When a user fires off a search query, I query Solr and retrieve the search results which can then be displayed.
My question is - how do I find out which facet fields and terms are applicable to the search results?
To be clear - different categories of products have different facet fields and I want to find a way to bring back the most relevant facet fields for the search results that have been returned. I don't want to have to specify the fields - I'd like Solr to identify the relevant ones for me.
Thanks in advance!
I would recommend looking over all of the Simple Facet Parameters on the Solr Wiki, especially the examples at the bottom as they will show you all of the possible ways that you can configure the faceting results for your queries.
If I am understanding your question correctly... by default faceting will only bring back facets/counts based on the documents in the result set. However to make those more relevant to the search, you should set the facet.mincount to something other than the default value of 0. eg. &facet.mincount=1. But, again please refer to the documentation on how this works and can be applied to your scenario.
Im having the same problem.
What I eventually did was to query Solr for the top 50 hits for a given query and then collect the names of the properties set on those products. I then do another query with the facet fields set to the product properties I found first time around.

Resources