how can I add weight to search term when searching by sphinx? - search

how can I add weight to search term when searching by sphinx ?
example:
Assume that the users types this search:
" I'd like to play soccer (A.K.A football) "
and assume that I do some processing on this sentence to simplify it to "soccer football"
Now I want to give more weight to search results that have "soccer" than those having "football"
How do I do that in Sphinx, please notice that I've seen answers here that mentioned that it's not possible, but I've seen an article about such possibility starting from sphinx 2.01 but it doesn't have further description

Duplicate the term you would like to amplify.
->setMatchMode(SPH_MATCH_EXTENDED)
->setRankingMode(SPH_RANK_WORDCOUNT)
->Query('"soccer soccer soccer soccer football"/1',$index);

Related

how azure search treat string like "Good Phase" To search on cloud db

I need technical help regarding my Azure document search
below my sample code
`var searchText = "Good Phase"
var searchData = indexClient.Documents.Search(searchText,searchParameters)`
I need to know this document search which is searchText = "Good Phase"
how azure document treat this "Good Phase" to search
means like
1:- Good AND Phase (with AND operator)
2:- Good OR Phase (With OR Operator)
When searching text such as “Good phase”, the search text is tokenized so that your terms will be separated by white space to two terms: “Good” and “phase” and the search results will be either term.
If you want all the terms to match you can specify searchmode=all, the default value is any.
More details you can find here:
https://learn.microsoft.com/en-us/rest/api/searchservice/search-documents
And also another good source:
https://learn.microsoft.com/en-us/azure/search/search-lucene-query-architecture
which explains how full text search works in Azure Search.
Thanks!
here is link answer by Mr Liam Cavanagh
https://social.msdn.microsoft.com/Forums/azure/en-US/2eb93403-afc5-4d99-a1c8-2e29ca6026a5/azure-document-search-default-nature-for-searching-text-on-azure-db?forum=azuresearch

How do I perform a partial search while preserving order using solr?

Using Solr 4.0, I have a field Title_t(to store titles of books) which is of type TextField. Assuming that these are the following titles stored in my db:
Physics Guide
Tutorial on Theoretical Physics
The General Physics
Book
If one wants to search for a title "Physics Guide", then one could use
Title_t:physics G*
this shows up all results
Physics Guide
Tutorial on Theoretical Physics
The General Physics Book
Now, to my question:
Why isnt the filter not showing only the "Physics Guide" result?
Since the search criteria is "physics G*" and not "*physics G *", only one result should be displayed .Is there a way to preserve order in the search key word?
After parsing you query Title_t:physics G* will become like
Title_t:physics df:G*
df here is default field(usually it will be text, check your config files).
and default operator will OR. so it returns documents with Title_t having term 'physics' and documents with any fields copied default field with words starting with G.
Try with ComplexPhraseQueryParser
q={!complexphrase inOrder=true}Title_t:"physics G*"

Implementing search : Identifying known keywords

I have implemented search functionality for my e-Commerce website using elastic search. The basic structure is like, each product has a title and whatever the user enters I search the exact string using elastic and return the result.
Now I notice that most of the search phrases (almost 90%) follow a similar pattern. It contains:
Brand name of the product (Apple, Nokia etc.)
Category of the product (phone, mobile phone, smartphone etc.)
Model name of the product (iPhone 6S, Lumia 950 etc.)
Now I think if I am able to identify the specific components, then I can return better results than just text match.
I have list of brands, categories and models. If i am able to identify the terms present, then I can request elasticsearch with that field specifically
For example, a search string of "Apple iPhone 5S", I should be able to deduce that brand=Apple.
EDIT: More details as asked in comments
Structure of document:
I have a single index and each document ID is the SKU of the product and it contains the following fields
title (Apple iPhone 5S)
brand (Apple)
categ (Electronics)
sub_categ (Smartphones)
model (iPhone 5S)
attribs (dictionary of product attributes particular to each sub_categ like {"color": "gold", "memory": "32 GB", "battery": "1570 mAh"})
price
Use Case:
Now when the user searches for phrase "iphone 5s battery", elastic returns search results which returns even the phone. (I agree the relevance score matches better for battery)
What I am trying to achieve is, I have master list of sub categories. So if any word from the search phrase is present in the master list, then i would search on elasticsearch with query ["must": {"sub_categ": "battery"}]. So the result from "Smartphones" sub category would not be fetched from elastic. I wish to replicate this across multiple fields like brand, category etc
My question is, how do I find if brand or any other particular word from the master list if present in the search phrase quickly? The only option i could think of is, looping through the master list and check if the word is present in the search phrase. If present, then keep note of it and do the same across all master list field (brand, categ, sub categ). Then generate the query with must and then querying them. I wish to know if there is a better way of accomplishing it.
The person in the Lucene world who has spoken the most on this topic is Ted Sullivan. (He calls this "auto-filtering", and has a component which does this available for Solr)
I realize you're using Elasticsearch, but Ted's component works by introspecting FieldCache data (exposed by Lucene) so should be possible to implement something very similar with Elasticsearch (look at the code).
There is also a discussion in this article about how to create a separate index for providing pre-query intelligence like you've described (e.g. your term "Apple" is most frequently found in the company field).

How do I deal with multiple word keyphrases and exact search in Solr?

How do I deal with multiple word keyphrases and exact search in Solr?
Hi. I need some help on the following issue:
I am indexing a list of shops of which each shop has a list of productwords that contain single keyword keyphrases like 'bike' and multiple keyword keyphrases like 'red bike'.
Example: Store A sells 'ipad' and 'iphone'. Store B sells 'ipad accessoires' and 'iphone', Store C sells 'ipad' and 'ipad accessoires'
When a user performs a search for 'ipad' I want only the stores that have a exact match on 'ipad' (i.e. only store A and C) to show up in the results.
In my current solr setup a keyphrase like 'ipad accessoires' gets tokenized to 'ipad' and 'accessoires' and when a user searches for 'ipad' store B shows up as well. How do I get a keyphrase like 'ipad accessoires' in the index with solr understanding it's actually 1 keyphrase/token to match upon.
Any help would be greatly appreciated!
If you are ready to try something different check upon Percolate Query in Elastic Search.
This is probably exactly what you are trying to do a reverse matching somthing link Google adwords.

Solr searching within a dictionary file

I was wondering if there is something out of the box from Solr which would allow me to search within a dictinary file (containing words and phrases) to returning all the phrases that contains my search terms.
For example, my dictionary file could have:
red car
blue bike
big bike tires
When I search 'bike', I expect to see
blue bike
big bike tires
And when I search 'big tires', i expect to see
big bike tires
Is there anything from Solr that could support this? I was looking into the SpellCheckComponent but it would only support prefix searches.
Basically, I would like to achieve solr searches (token searching) but against a dictionary file (this same file would also be used for autosuggest).
Any advice or direction would be appreciated.
Why not store such phrases in the index itself? The schema can be:
type: suggest_phrase #other types are product or review_article
phrase: big bike tires
So your search for big tires would be:
..fq=type:suggest_phrase&q=phrase:big tires

Resources