Relevancy searching in elastic search, - elasticsearch

Currently i am implementing product search in my application using elastic-search,i was able to implement basic search by applying steamers(to get root terms) and analyzers(remove 's' and stuff like that), but when searching for products like "Red Shrimp" i am getting "red shrimps" , "shrimps" and also some unrelated products which contain "Red"(Red gram,Red onion,Red battey) which shouldn't happen.
Can any one suggest me how to eliminate this irrelevant section of results,I am grateful to any valid suggestion.
Thanks,
I

you can use elastic "Common Terms Query" with minimum_should_match option
Reference Link : https://www.elastic.co/guide/en/elasticsearch/reference/6.1/query-dsl-common-terms-query.html

Related

all category search ecommerce suggest popular search

I made a ecommerce app for learning purpose.
I have implement search box using elasticsearch, it can search and give suggestion item's name.
example :
input -> macbo
suggestion :
laptop macbook 14
laptop mackbok xxxxxx
now I want implement search box for "general" means nothing category selected so when we type a something it's not give us spesific item's name but something like most popular search query/terms.
I cannot figured out how the basic ideas behind this, can someone give me some advise.
Thanks
I guess you are looking for suggestions, not the actual search results and If I understand this correctly then you could use the term suggestor available in Elastisearch.

Search algorithm options for ontology querying?

I have developed a tool that enables searching of an ontology I authored. It submits the searches as SPARQL queries.
I have received some feedback that my search implementation is all-or-none, or "binary". In other words, if a user's input doesn't exactly match a term in the ontology, they won't get any hit at all.
I have been asked to add some more flexible, or "advanced" search algorithms. Indexing and bag-of-words searching were suggested.
Can anyone give some examples of implementing search methods on an ontology that don't require a literal match?
FIrst of all, what kind of entities are you trying to match (literals, or string casts of URIs?), and what kind of SPARQL queries are you running now? Something like this?
?term ?predicate "user input" .
If you are searching across literals, you can make the search more flexible right off the bat by using case-insensitive regular expression filtering, although this will probably make your searches slower, and it won't catch cases where some of the word tokens are present but in a different order. In the following example, your should probably constrain the types of ?term and ?predicate first, or even filter on a string datatype on ?userInput
?term ?predicate ?someLiteral .
FILTER(regex(?someLiteral), "user input", "i"))
Several triplestores offer support for full-text searching and result scoring. These are often extensions to the SPARQL language.
For example, Virtuoso and some others offer a bif:contains predicate. Virtuoso also offers the faceted search web interface (plus a service, I think.) I have been pleased with the web-based full text search in Blazegraph and Stardog, but I can't say anything at this point about using them with a SPARQL query to get a score on a search pattern. Some (GraphDB) even support explicit integration with Lucene or Solr*, so you may be able to take advantage of their search languages.
Finally... are you using a library like the OWL API or RDF4J to access your ontology? If so, you could certainly save the relationships between your terms and any literals in a Java native data structure, and then directly use a fuzzy search component like Lucene to index each literal as a "document" and then search the user input across the index.
Why don't you post your ontology and give an example of a search you would like to peform in a non-binary way. I (or someone else) can try to show you a minimal implementation.
*Solr integration only appears to be offered in the commercially-licensed version of GraphDB

How do I see/debug the way SOLR find it's results?

Let's say I search for "ABLS" and the SOLR returns a result that to me does not make any sense.
How can I debug why SOLR picked this record to be returned?
debugQuery=true would help you get the detailed score calculation and the explanation for each scores.
An over view of the scoring is available at link
For detailed explaination of the debug information you can refer Link
You could add debugQuery=true&indent=true to the url and examine the results. You could also use the analysis tool in solr. Go to the admin and click analysis. You would need to read the wiki to understand either of these more in depth.
queryDebug will give you knowledge about why your scoring looks like it does (end how every field is relevant).
I will get some results that you are not understand and play with them with Solr's analysis
You should find it under:
/admin/analysis.jsp?highlight=on
Alternatively turn on highlighting over your results to see what is actually matching in your results
Solr queries are full of short parameters, hard to read and modify, especially when the parameters are too many.
And after it is even harder to debug and understand why a document is more or less relevant than another. The debug explain output usually is a three too big to fit in one page.
I found this Google Chrome extension useful to see Solr Query explain and debug in a clear manner.
For those who still use very old version of solr 3.X, "debugQuery=true" will not put the debug information. you should specify "debugQuery=on".
There are two ways of doing that. First is the query level, which means adding the debugQuery=on to your query. That will include a few things:
parsed query
debug timing information
detailed scoring information which helps you with analysis of why a give document is given a score.
In addition to that, you can use the [explain] transformer and add it to your fl parameter. For example ...&fl=*,[explain], which will result in your documents having the scoring information as another field.
The scoring information can be quite extensive and will include calculations done by the similarity algorithm. If you would like to learn more about the similarities and the scoring algorithm in Solr, have a look at this my and my colleague Radu from Sematext talk from the Activate conference: https://www.youtube.com/watch?v=kKocQdYGVJM

Magento - Exclude Search Term

Does anyone know if there is any way to exclude certain words from being searched for in Magento?
For example: Say I have a store that sells hats, I want to exclude the word “hats” from being searched, so if someone searches for “black hats” the it would only return results for “black”, because all the products are hats anyway, and if it allowed “hats” in the search term then it would return ALL hats.
Any ideas?
I am not sure you really need to do this, given the scenario you outlined. Magento uses like or fulltext as available search options (set via admin > system > configuration > catalog > catalog search), and neither of those would return all hats if the search query was "black hats."
If you still feel the need to exclude certain search terms, you could either extend app/code/core/Mage/CatalogSearch/Model/Query.php in the local code pool, and add a method that removes any unwanted search terms. Or - and this is the approach I would take - create a small module with an observer that catches the controller_action_predispatch event. This would allow you to sanitize/modify the query parameters to remove any search terms that should excluded, before the query ever gets passed to the ResultController.php.

How to do SQL IN like query in hibernate search

A simulating scenario is:
Search for books whose content contains "success" AND author is in a list of passed names(could be thousands of).
I looked into filter:
http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#query-filter
Seams like hibernate search has no native support of this.
What is recommended approach for this problem? I think I am not alone.
Thanks for any inputs.
Let me post my current solution.
Get the search results with minimal projections for the keywords, and loop through the results to get only matching ones from the IN list.
I am not using filter.
Open to other alternatives once convinced.
If you look here http://lucene.apache.org/java/2_4_1/queryparsersyntax.html (at the end "Field Grouping"), you can write a query with something like :
content:success AND author:("firstname" "secondname" "thirdname" ...)

Resources