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
Related
I have added the data to solr.
Name field values are: "batman","bat man","bat-man"
so if a user searched for "btman" the result should show all the above values in search.
I found the query like: localhost:8983/solr/test/select?q=Name%3Abtman~2
but it won't work in all cases.
I need suggession for the Solr query which fetch the result with typos and recomendations.
IMO, you should use Synonym filter in Solr.
You basically need to create a Synonym file and pass it as an input where you think such spelling mistakes would occur.
Solr comes with SpellCheck Compponent. The SpellCheck component is designed to provide inline query suggestions based on other, similar, terms. The basis for these suggestions can be terms in a field in Solr, externally created text files, or fields in other Lucene indexes.
In your case the spellcheck component will help you to achieve the same.
Please refer the solr documentation for configuring the spellcheck component.
Solr SpellCheck Compenent
If you query to the below url :
http://localhost:8986/solr/upgrade1/spell?q=retil&spellcheck.build=true&spellcheck=on&wt=xml
The result page :
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".
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.
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.
I'm currently using Local Solr for doing geo searching. It takes in lat and long parameters as well as a search query. I want to create nearby functionality, where I don't need to provide a location and not a search query. Is there a way to provide a wildcard query that matches all elements then order by the distance? Is the best to create another field and place the same value in all fields?
Thanks.
You can use the query *:* to match all values in all fields.
See http://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F for an example on how to query all documents using the *:* wildcard.
See also http://wiki.apache.org/solr/SolrQuerySyntax for general Solr syntax help.
You may use Solr spatial search to sort by distance, and your query can be *:* if you want to pull all documents from your index.
eg: ?q=*:*&sfield=search_field&pt=22.12,-55.56&sort=geodist() asc
http://wiki.apache.org/solr/SpatialSearch