I am looking for getting auto complete suggestions using Solr based on keyword as well as geolocation. Is there a way the 'Suggester' component or any other way, Solr can take in multiple fields for auto completion?
For e.g. if I have a restaurants database and I want to get suggestions using keyword e.g. 'Piz', the results should be based both on the keyword 'Piz' and also the locations that are close to certain latitude, longitude.
Is there a way to do it in Solr ?
Thanks.
you create a handler that:
in the index analyzer chaing, use EdgeNGram to math what the user entered so far
boost results with geodist(): play around with recip() etc until you get desired weight on the location boosting
call that handler and pass current location and user entered chars and you are done
Related
Azure Search by default highlights search results with <em> tag. I've met with situation where user uploads document with that tag inside:
<em>Today</em> topic will be...
When i would search for "topic" i would get:
<em>Today</em> <em>topic</em> will be...
And i wouldn't be able to distinguish the right highlight.
I know that i can modify highlight_pre_tag and highlight_post_tag so i would avoid this in this particular situation. But is there other way to encode this tags before appyling highlighs?
EDIT:
By encoding i mean getting something like this:
<em>Today</em> <em>topic</em> will be...;
So I can send it to frontend and then display <em> from "Today" as <em> and use <em> in "topic" to highlight it to yellow.
Azure Search doesn't provide any built-in mechanism to modify the "raw" content of a document if you are using the Index API directly, however, if you are using one of our built-in indexers, you can look into using the field mapper functions (such as the UrlEncode function) or create your own custom skill (if you want to only apply very specific rules) to transform the documents in transit from your data source to the search index.
Alternatively, we've seen customers use custom highlight pre and post tags that are easily recognizable (and unlikely to be mistaken for original content) and then using a simple search and replace function in their client application to transform those back into the desired tag.
For example, using
pre-tag : "!HIGHLIGHT_START!" and post-tag :"!HIGHLIGHT_END!"
and then using
String.Replace("!HIGHLIGHT_START!", "<em>")
before displaying the results in their application. That way, any client-side logic that requires finding the actual highlights can use the custom tags, while still showing the desired tag in the UX.
I am pretty new to SOLR and we have a requirement where I have to modify one of the JSON property value from incoming request to get updated and stored. Something like the below one.
e.g.
{
"name":"Google,CA,94043"
}
When I add this JSON via add/update documents using SOLR admin. I want this name to be stored as just Google. So when I do a search(query) . from SOLR admin it should list name as Google not "Google,CA,94043"
I have added FieldType with PatternReplaceFilterFactory and referenced the same to name field. The result is not appearing with the updated one. But when I analyze field value (index/query) using the admin tool it has the values correctly. Not sure how to achieve this.
Let me know if anyone has steps on how to achieve this.
I am using the solr (6.5.1) suggester to return autocomplete results.
I am trying to display a price and a thumbnail with the autocomplete results but can't find a way to do this.
Is there a way to return more fields?
I see these two questions from two years ago that seem to be trying to accomplish what I want, and both say that at the time it is not doable.
Solr Suggestion with multiple payloads
Returning an entire Document on Solr Suggestion
Has anything changed since two years ago?
Is there a different way that this can be accomplished?
just put all info you need into a field, and use that field as payload. For example you could:
append some string info, separated by |: payload:"17|/path/to/thumbnail"
or you could use Solr BinaryField and put a Java pojo containing the info you need there serialized
I would go the simple route, the first one.
Our Solr is configured to return ALL results if no valid search parameters are passed in. For example:
http://localhost:8983/solr/collection1/select?rows=1&title=bar is a valid search (title is a valid field) and it returns the proper number of results (1 out of many results). But... http://localhost:8983/solr/collection1/select?rows=1&foo=bar returns one out of the entire collection (foo is not a valid field).
I read that there is a way to configure Solr to return NO results by default (instead of all). It said "adjust the requestHandler config to return all results by default" (which I assume means there is a way to return none by default) but I cannot find anything online about how to actually do this.
The reason we want this is because we're implementing a blacklist of fields that we don't want the user to search on, but by doing this, it allows all other fields through and we'd like those to return no results (or even better - an error saying the field is invalid).
Solr is being called through our API that we wrote, so even if we could add on a parameter to each call to make it return no results by default (noResultsIfNoValidSearch=true or something), that would work.
So, any ideas on how to configure Solr to return NO results by default? Thanks!
Add echoParams=all into your query to see everything that the request has, coming from all configuration sources.
Most likely you define q=*:* somewhere in your configuration, that's what causing returning everything. Remove that and you should get nothing.
If you are using eDixMas, you can look into uf parameter which allows to restrict the fields users are allowed to query.
To allow all fields except title, use uf=*-title
The easiest thing that comes to mind is to set the rows parameter to 0 in your API or config, depending on your requirements.
How do I get only a row which matches my query: ?q=taxonomy_ids:1/636/*
Got that result:
Want only: <str>1/636/587</str>
There is no easy way. However, there is a trick, where you use a match highlighter and use those results instead of the results returned from the search itself. You may want to configure PRE/POST highlight tags to empty strings. There was an article on the web about somewhere, but I can't find it again.
The disadvantage is that you get your results twice. Once as docs and once as highlight.
The other option is a custom component that hooks into Lucene's explain structure.