Apache Solr search query when user made a TYPO in text - solr

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 :

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

Similarity/approximate queries in Solr

What is the simplest way to query Solr for the documents that contain text similiar to a (longish) passage. This is similar to what ElasticSearch match queries do or what probabilistic search engines like Indri do by default. This is something between an and and an or query. None of the terms is required, but you get documents that contain many of the terms. You can also just pass a passage of raw text to the engine and it returns documents with high term overlap with the passage without having to try to parse or tokenize the text in the client. The best I option can see in the Solr query reference is to tokenize the query text myself and then insert an OR between each pair of terms and return the top N results. Is there more concise way of doing it with Solr?
The answer above is correct. You can choose to find documents similar to another document in the index, similar to a given external URL or similar to some given text. You can choose what field(s) to target and various other parameters. Here's the official Solr Reference Guide documentation page for MLT: https://cwiki.apache.org/confluence/display/solr/MoreLikeThis

Solr Suggester - How do I filter autocomplete results

I want to filter the auto complete results from my suggester
Lets say I have a book table
Table (Id Guid, BookName String, BookOwner id)
I want each user to get a list to autocomplete from its own books.
I want to add something like the
http://.../solr/vault/suggest?q=c&fq=BookOwner:3
This doesnt work.
What other ways do I have to implement it?
Solr Spell Check is a completely different index and it stores just the information from the field marked for Spell suggestion.
It does not have any reference of the document from which it had originated from.
So the filter query with suggester would not work.
The way you wanted it, using fq is working fine in the version Solr 6.4.1 (and probably higher versions too)
http://.../solr/vault/suggest?q=c&fq=BookOwner:3

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

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.

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