You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Aman Deep Singh <am...@gmail.com> on 2017/06/19 12:27:24 UTC

Give boost only if entire value is present in Query

Hi,
I have a problem ,I need to give the boost to a particular field if and
only if the query contains entire field value (String contains like
feature).
e.g. if Field value is ABC DEF
It should match if user query is like ABC DEF XYZ  or XYZ ABC DEF, But it
should not match when user query is like ABC or ABC XYZ
I'm using Solr-6.6.0
also using edismax parser

I tried creating the custom field like

<fieldType name="cust_shingle" class="solr.TextField"
enableGraphQueries="false">
    <analyzer type="index">
      <tokenizer class="solr.KeywordTokenizerFactory"/>
      <filter class="solr.PatternReplaceFilterFactory" pattern=" "
replace="all" replacement=""/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
    <analyzer type="query">
      <tokenizer class="solr.WhiteSpaceTokenizerFactory"/>
      <filter class="solr.ShingleFilterFactory" minShingleSize="2"
outputUnigrams="true" maxShingleSize="5" tokenSeparator=" "/>
      <filter class="solr.PatternReplaceFilterFactory" pattern=" "
replace="all" replacement=""/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>


But it creating the synonyms query like (user query= 7 armour)

+(((nameSearchNoSyn:7 nameSearchNoSyn:armour)~2)^9.0 | ((brandSearch:7
brandSearch:armour)~2) |

 ((nameSearch:7 nameSearch:armour)~2)^4.0 | (keywords:7 armour)^11.0 |

((descSearchNoSyn:7 descSearchNoSyn:armour)~2)^2.0 |

*((Synonym(brandSearchQueryShingle:7 brandSearchQueryShingle:7armour)
brandSearchQueryShingle:armour)~2)^10.0* |

((descriptionSearch:7 descriptionSearch:armour)~2) |
(categoryKeywords:7 armour)^11.0) ((nameSearch:"7 armour"~5)^9.0 |

 (brandSearch:"7 armour"~5)^8.0 | (descriptionSearch:"7
armour"~5)^2.0) ((nameSearch:"7 armour")^9.0 |

(descriptionSearch:"7 armour")^2.0)


which again is not matching docs  ,

Any idea how to boost the document if the user query contains exact
value of that field


my request handler is as


<lst name="/browse">
<str name="name">/browse</str>
<str name="class">solr.SearchHandler</str>
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="wt">velocity</str>
<str name="indent">true</str>
<str name="v.template">browse</str>
<str name="v.layout">layout</str>
<str name="title">Solritas</str>
<str name="defType">edismax</str>
<str name="qf">
nameSearch^4 brandSearch *brandSearchQueryShingle*^10
descriptionSearch categoryKeywords^11 keywords^11 nameSearchNoSyn^9
descSearchNoSyn^2
</str>
<str name="ps">5</str>
<str name="pf">
nameSearch^9 brandSearch^8 descriptionSearch^2 categoryKeywords^10 keywords^10
</str>
<str name="pf2">nameSearch^9 descriptionSearch^2</str>
<str name="ps2">0</str>
<str name="df">searchFields</str>
<str name="mm">100%</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
<str name="facet.mincount">1</str>
<str name="facet.range.other">after</str>
<str name="spellcheck">true</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.alternativeTermCount">2</str>
<str name="spellcheck.maxResultsForSuggest">5</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.collateExtendedResults">true</str>
<str name="spellcheck.maxCollationTries">5</str>
<str name="spellcheck.maxCollations">10</str>
<str name="sow">*false*</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</lst>


Thanks,

Aman Deep Singh

Re: Give boost only if entire value is present in Query

Posted by Aman Deep Singh <am...@gmail.com>.
It was not matching the results for that particular field
below is the debug data

(+DisjunctionMaxQuery((((nameSearchNoSyn:7 nameSearchNoSyn:armour)~2)^9.0 |
((brandSearch:7 brandSearch:armour)~2) | ((nameSearch:7
nameSearch:armour)~2)^4.0 | (keywords:7 armour)^11.0 | ((descSearchNoSyn:7
descSearchNoSyn:armour)~2)^2.0 | ((Synonym(brandSearchQueryShingle:7
brandSearchQueryShingle:7armour) brandSearchQueryShingle:armour)~2)^10.0 |
((descriptionSearch:7 descriptionSearch:armour)~2) | (categoryKeywords:7
armour)^11.0)) DisjunctionMaxQuery(((nameSearch:"7 armour"~5)^9.0 |
(brandSearch:"7 armour"~5)^8.0 | (descriptionSearch:"7 armour"~5)^2.0))
DisjunctionMaxQuery(((nameSearch:"7 armour")^9.0 | (descriptionSearch:"7
armour")^2.0)))/no_coord
</str>
<str name="parsedquery_toString">
+(((nameSearchNoSyn:7 nameSearchNoSyn:armour)~2)^9.0 | ((brandSearch:7
brandSearch:armour)~2) | ((nameSearch:7 nameSearch:armour)~2)^4.0 |
(keywords:7 armour)^11.0 | ((descSearchNoSyn:7
descSearchNoSyn:armour)~2)^2.0 | ((Synonym(brandSearchQueryShingle:7
brandSearchQueryShingle:7armour) brandSearchQueryShingle:armour)~2)^10.0 |
((descriptionSearch:7 descriptionSearch:armour)~2) | (categoryKeywords:7
armour)^11.0) ((nameSearch:"7 armour"~5)^9.0 | (brandSearch:"7
armour"~5)^8.0 | (descriptionSearch:"7 armour"~5)^2.0) ((nameSearch:"7
armour")^9.0 | (descriptionSearch:"7 armour")^2.0)
</str>
<lst name="explain">
<str name="MTA-0114843">
231.43768 = sum of: 122.80731 = max of: 122.80731 = sum of: 39.3418 =
weight(nameSearchNoSyn:7 in 11675) [SchemaSimilarity], result of: 39.3418 =
score(doc=11675,freq=1.0 = termFreq=1.0 ), product of: 9.0 = boost
3.6432905 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq
+ 0.5)) from: 38829.0 = docFreq 1483961.0 = docCount 1.199825 = tfNorm,
computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength /
avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 = parameter k1 0.75 =
parameter b 11.993984 = avgFieldLength 7.111111 = fieldLength 83.465515 =
weight(nameSearchNoSyn:armour in 11675) [SchemaSimilarity], result of:
83.465515 = score(doc=11675,freq=1.0 = termFreq=1.0 ), product of: 9.0 =
boost 7.729415 = idf, computed as log(1 + (docCount - docFreq + 0.5) /
(docFreq + 0.5)) from: 652.0 = docFreq 1483961.0 = docCount 1.199825 =
tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b *
fieldLength / avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 = parameter k1
0.75 = parameter b 11.993984 = avgFieldLength 7.111111 = fieldLength
10.923981 = sum of: 5.468917 = weight(brandSearch:7 in 11675)
[SchemaSimilarity], result of: 5.468917 = score(doc=11675,freq=1.0 =
termFreq=1.0 ), product of: 7.810959 = idf, computed as log(1 + (docCount -
docFreq + 0.5) / (docFreq + 0.5)) from: 600.0 = docFreq 1481730.0 =
docCount 0.7001595 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 *
(1 - b + b * fieldLength / avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 =
parameter k1 0.75 = parameter b 1.2507185 = avgFieldLength 2.56 =
fieldLength 5.4550633 = weight(brandSearch:armour in 11675)
[SchemaSimilarity], result of: 5.4550633 = score(doc=11675,freq=1.0 =
termFreq=1.0 ), product of: 7.7911725 = idf, computed as log(1 + (docCount
- docFreq + 0.5) / (docFreq + 0.5)) from: 612.0 = docFreq 1481730.0 =
docCount 0.7001595 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 *
(1 - b + b * fieldLength / avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 =
parameter k1 0.75 = parameter b 1.2507185 = avgFieldLength 2.56 =
fieldLength 54.581028 = sum of: 17.485245 = weight(nameSearch:7 in 11675)
[SchemaSimilarity], result of: 17.485245 = score(doc=11675,freq=1.0 =
termFreq=1.0 ), product of: 4.0 = boost 3.6432905 = idf, computed as log(1
+ (docCount - docFreq + 0.5) / (docFreq + 0.5)) from: 38829.0 = docFreq
1483961.0 = docCount 1.199825 = tfNorm, computed as (freq * (k1 + 1)) /
(freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from: 1.0 =
termFreq=1.0 1.2 = parameter k1 0.75 = parameter b 11.993984 =
avgFieldLength 7.111111 = fieldLength 37.095783 = weight(nameSearch:armour
in 11675) [SchemaSimilarity], result of: 37.095783 =
score(doc=11675,freq=1.0 = termFreq=1.0 ), product of: 4.0 = boost 7.729415
= idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5))
from: 652.0 = docFreq 1483961.0 = docCount 1.199825 = tfNorm, computed as
(freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength /
avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 = parameter k1 0.75 =
parameter b 11.993984 = avgFieldLength 7.111111 = fieldLength 22.929073 =
sum of: 6.5367765 = weight(descSearchNoSyn:7 in 11675) [SchemaSimilarity],
result of: 6.5367765 = score(doc=11675,freq=2.0 = termFreq=2.0 ), product
of: 2.0 = boost 2.2815151 = idf, computed as log(1 + (docCount - docFreq +
0.5) / (docFreq + 0.5)) from: 151552.0 = docFreq 1483926.0 = docCount
1.4325516 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b
* fieldLength / avgFieldLength)) from: 2.0 = termFreq=2.0 1.2 = parameter
k1 0.75 = parameter b 97.52203 = avgFieldLength 83.591835 = fieldLength
16.392298 = weight(descSearchNoSyn:armour in 11675) [SchemaSimilarity],
result of: 16.392298 = score(doc=11675,freq=1.0 = termFreq=1.0 ), product
of: 2.0 = boost 7.7172055 = idf, computed as log(1 + (docCount - docFreq +
0.5) / (docFreq + 0.5)) from: 660.0 = docFreq 1483926.0 = docCount
1.0620618 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b
* fieldLength / avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 = parameter
k1 0.75 = parameter b 97.52203 = avgFieldLength 83.591835 = fieldLength
11.464537 = sum of: 3.2683883 = weight(descriptionSearch:7 in 11675)
[SchemaSimilarity], result of: 3.2683883 = score(doc=11675,freq=2.0 =
termFreq=2.0 ), product of: 2.2815151 = idf, computed as log(1 + (docCount
- docFreq + 0.5) / (docFreq + 0.5)) from: 151552.0 = docFreq 1483926.0 =
docCount 1.4325516 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 *
(1 - b + b * fieldLength / avgFieldLength)) from: 2.0 = termFreq=2.0 1.2 =
parameter k1 0.75 = parameter b 97.52203 = avgFieldLength 83.591835 =
fieldLength 8.196149 = weight(descriptionSearch:armour in 11675)
[SchemaSimilarity], result of: 8.196149 = score(doc=11675,freq=1.0 =
termFreq=1.0 ), product of: 7.7172055 = idf, computed as log(1 + (docCount
- docFreq + 0.5) / (docFreq + 0.5)) from: 660.0 = docFreq 1483926.0 =
docCount 1.0620618 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 *
(1 - b + b * fieldLength / avgFieldLength)) from: 1.0 = termFreq=1.0 1.2 =
parameter k1 0.75 = parameter b 97.52203 = avgFieldLength 83.591835 =
fieldLength 87.39184 = max of: 87.39184 = weight(brandSearch:"7 armour"~5
in 11675) [SchemaSimilarity], result of: 87.39184 =
score(doc=11675,freq=1.0 = phraseFreq=1.0 ), product of: 8.0 = boost
15.602131 = idf(), sum of: 7.810959 = idf, computed as log(1 + (docCount -
docFreq + 0.5) / (docFreq + 0.5)) from: 600.0 = docFreq 1481730.0 =
docCount 7.7911725 = idf, computed as log(1 + (docCount - docFreq + 0.5) /
(docFreq + 0.5)) from: 612.0 = docFreq 1481730.0 = docCount 0.7001595 =
tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b *
fieldLength / avgFieldLength)) from: 1.0 = phraseFreq=1.0 1.2 = parameter
k1 0.75 = parameter b 1.2507185 = avgFieldLength 2.56 = fieldLength
21.238518 = weight(descriptionSearch:"7 armour"~5 in 11675)
[SchemaSimilarity], result of: 21.238518 = score(doc=11675,freq=1.0 =
phraseFreq=1.0 ), product of: 2.0 = boost 9.99872 = idf(), sum of:
2.2815151 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq
+ 0.5)) from: 151552.0 = docFreq 1483926.0 = docCount 7.7172055 = idf,
computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:
660.0 = docFreq 1483926.0 = docCount 1.0620618 = tfNorm, computed as (freq
* (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength))
from: 1.0 = phraseFreq=1.0 1.2 = parameter k1 0.75 = parameter b 97.52203 =
avgFieldLength 83.591835 = fieldLength 21.238518 = max of: 21.238518 =
weight(descriptionSearch:"7 armour" in 11675) [SchemaSimilarity], result
of: 21.238518 = score(doc=11675,freq=1.0 = phraseFreq=1.0 ), product of:
2.0 = boost 9.99872 = idf(), sum of: 2.2815151 = idf, computed as log(1 +
(docCount - docFreq + 0.5) / (docFreq + 0.5)) from: 151552.0 = docFreq
1483926.0 = docCount 7.7172055 = idf, computed as log(1 + (docCount -
docFreq + 0.5) / (docFreq + 0.5)) from: 660.0 = docFreq 1483926.0 =
docCount 1.0620618 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 *
(1 - b + b * fieldLength / avgFieldLength)) from: 1.0 = phraseFreq=1.0 1.2
= parameter k1 0.75 = parameter b 97.52203 = avgFieldLength 83.591835 =
fieldLength
</str>



On Tue, Jun 20, 2017 at 7:33 PM alessandro.benedetti <a....@sease.io>
wrote:

> Interesting.
> it seems almost correct to me.
> Have you explored the content of the field ( for example using the schema
> browser) ?
> When you say " don't match" it means you don't get results at all or just
> the boost is not applied ?
> I would recommend to simply the request handler, maybe just introducing a
> piece step by step and verifying you are getting what you want.
>
> Regards
>
>
>
> -----
> ---------------
> Alessandro Benedetti
> Search Consultant, R&D Software Engineer, Director
> Sease Ltd. - www.sease.io
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Give-boost-only-if-entire-value-is-present-in-Query-tp4341714p4341951.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Give boost only if entire value is present in Query

Posted by "alessandro.benedetti" <a....@sease.io>.
Interesting.
it seems almost correct to me.
Have you explored the content of the field ( for example using the schema
browser) ?
When you say " don't match" it means you don't get results at all or just
the boost is not applied ?
I would recommend to simply the request handler, maybe just introducing a
piece step by step and verifying you are getting what you want.

Regards



-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
View this message in context: http://lucene.472066.n3.nabble.com/Give-boost-only-if-entire-value-is-present-in-Query-tp4341714p4341951.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Give boost only if entire value is present in Query

Posted by Aman Deep Singh <am...@gmail.com>.
Sorry Rick,
I didn't get it.
How will you give boost on other field when querying on some other field.
Or if you query on copy keyword tokenized field then it only matched when
entire query is matched.


On 20-Jun-2017 1:52 AM, "Rick Leir" <rl...@leirtech.com> wrote:

Aman,
Use a copyfield so you can have a second field that uses a different
analysis chain. In the new field you just created for the copyfield, use
the lowercase type, or create a type using KeywordTokenizer in the analysis
chain. Then match on the original field, and boost based on the new field.
Cheers
Rick

On June 19, 2017 11:01:49 AM EDT, Aman Deep Singh <am...@gmail.com>
wrote:
>Yes alessandro,
>I know  that their us some downsight of using sow =false but if don't
>use
>it then neither shingle nor bhram will work ,and these are required in
>my
>case/setup
>
>On 19-Jun-2017 8:18 PM, "alessandro.benedetti" <a....@sease.io>
>wrote:
>
>Isn't this a case where you don't want the query parser to split by
>space
>before the analyser ?
>Take a look to the "sow" param for the edismax query parser.
>In your case you should be ok but Be aware that is not a silver bullet
>for
>everything and that other problems could arise in similar scenarios
>[1].
>
>The *sow* Parameter
>Split on whitespace: if set to false, whitespace-separated term
>sequences
>will be provided to text analysis in one shot, enabling proper function
>of
>analysis filters that operate over term sequences, e.g. multi-word
>synonyms
>and shingles. Defaults to true: text analysis is invoked separately for
>each
>individual whitespace-separated term.
>
>[1]
>http://lucene.472066.n3.nabble.com/The-downsides-of-
>not-splitting-on-whitespace-in-edismax-the-old-albino-
>elephant-prob-td4327440.html
>
>
>
>-----
>---------------
>Alessandro Benedetti
>Search Consultant, R&D Software Engineer, Director
>Sease Ltd. - www.sease.io
>--
>View this message in context: http://lucene.472066.n3.
>nabble.com/Give-boost-only-if-entire-value-is-present-in-
>Query-tp4341714p4341735.html
>Sent from the Solr - User mailing list archive at Nabble.com.

--
Sorry for being brief. Alternate email is rickleir at yahoo dot com

Re: Give boost only if entire value is present in Query

Posted by Rick Leir <rl...@leirtech.com>.
Aman,
Use a copyfield so you can have a second field that uses a different analysis chain. In the new field you just created for the copyfield, use the lowercase type, or create a type using KeywordTokenizer in the analysis chain. Then match on the original field, and boost based on the new field.
Cheers
Rick

On June 19, 2017 11:01:49 AM EDT, Aman Deep Singh <am...@gmail.com> wrote:
>Yes alessandro,
>I know  that their us some downsight of using sow =false but if don't
>use
>it then neither shingle nor bhram will work ,and these are required in
>my
>case/setup
>
>On 19-Jun-2017 8:18 PM, "alessandro.benedetti" <a....@sease.io>
>wrote:
>
>Isn't this a case where you don't want the query parser to split by
>space
>before the analyser ?
>Take a look to the "sow" param for the edismax query parser.
>In your case you should be ok but Be aware that is not a silver bullet
>for
>everything and that other problems could arise in similar scenarios
>[1].
>
>The *sow* Parameter
>Split on whitespace: if set to false, whitespace-separated term
>sequences
>will be provided to text analysis in one shot, enabling proper function
>of
>analysis filters that operate over term sequences, e.g. multi-word
>synonyms
>and shingles. Defaults to true: text analysis is invoked separately for
>each
>individual whitespace-separated term.
>
>[1]
>http://lucene.472066.n3.nabble.com/The-downsides-of-
>not-splitting-on-whitespace-in-edismax-the-old-albino-
>elephant-prob-td4327440.html
>
>
>
>-----
>---------------
>Alessandro Benedetti
>Search Consultant, R&D Software Engineer, Director
>Sease Ltd. - www.sease.io
>--
>View this message in context: http://lucene.472066.n3.
>nabble.com/Give-boost-only-if-entire-value-is-present-in-
>Query-tp4341714p4341735.html
>Sent from the Solr - User mailing list archive at Nabble.com.

-- 
Sorry for being brief. Alternate email is rickleir at yahoo dot com 

Re: Give boost only if entire value is present in Query

Posted by Aman Deep Singh <am...@gmail.com>.
Yes alessandro,
I know  that their us some downsight of using sow =false but if don't use
it then neither shingle nor bhram will work ,and these are required in my
case/setup

On 19-Jun-2017 8:18 PM, "alessandro.benedetti" <a....@sease.io> wrote:

Isn't this a case where you don't want the query parser to split by space
before the analyser ?
Take a look to the "sow" param for the edismax query parser.
In your case you should be ok but Be aware that is not a silver bullet for
everything and that other problems could arise in similar scenarios [1].

The *sow* Parameter
Split on whitespace: if set to false, whitespace-separated term sequences
will be provided to text analysis in one shot, enabling proper function of
analysis filters that operate over term sequences, e.g. multi-word synonyms
and shingles. Defaults to true: text analysis is invoked separately for each
individual whitespace-separated term.

[1]
http://lucene.472066.n3.nabble.com/The-downsides-of-
not-splitting-on-whitespace-in-edismax-the-old-albino-
elephant-prob-td4327440.html



-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
View this message in context: http://lucene.472066.n3.
nabble.com/Give-boost-only-if-entire-value-is-present-in-
Query-tp4341714p4341735.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Give boost only if entire value is present in Query

Posted by "alessandro.benedetti" <a....@sease.io>.
Isn't this a case where you don't want the query parser to split by space
before the analyser ?
Take a look to the "sow" param for the edismax query parser.
In your case you should be ok but Be aware that is not a silver bullet for
everything and that other problems could arise in similar scenarios [1].

The *sow* Parameter
Split on whitespace: if set to false, whitespace-separated term sequences
will be provided to text analysis in one shot, enabling proper function of
analysis filters that operate over term sequences, e.g. multi-word synonyms
and shingles. Defaults to true: text analysis is invoked separately for each
individual whitespace-separated term.

[1]
http://lucene.472066.n3.nabble.com/The-downsides-of-not-splitting-on-whitespace-in-edismax-the-old-albino-elephant-prob-td4327440.html



-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
View this message in context: http://lucene.472066.n3.nabble.com/Give-boost-only-if-entire-value-is-present-in-Query-tp4341714p4341735.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Give boost only if entire value is present in Query

Posted by Aman Deep Singh <am...@gmail.com>.
Yes Susheel ,
I know that more token matched gives more weight but in my case if entire
match I want around x times boost but in case of partial match I want to
give nominal boost or normal boost,
Now in case of keyword token ziet or phrase query they work if and only if
the user query is exactly matched to the index value but in my case
Suppose index term is ABC DEF
I Want to give more boost even if user query is ABC DEF XYZ and so on , so
normal keyword tokenized field not work


On 19-Jun-2017 7:46 PM, "Susheel Kumar" <su...@gmail.com> wrote:

In general, the documents which has more or all terms matched against query
terms will be boosted higher per lucene tf/idf scoring.

So for document having ABC DEF queries like ABC DEF XYZ  or XYZ ABC DEF
will find a match(assuming q.op=AND)  and will be boosted higher compare to
documents with ABC or only DEF.

If you do not want match when user query is like ABC or ABC XYZ then you
have to use phrase queries or fields with keyword tokenizer etc.  and in
which case above queries will not work.

Thnx


On Mon, Jun 19, 2017 at 8:27 AM, Aman Deep Singh <am...@gmail.com>
wrote:

> Hi,
> I have a problem ,I need to give the boost to a particular field if and
> only if the query contains entire field value (String contains like
> feature).
> e.g. if Field value is ABC DEF
> It should match if user query is like ABC DEF XYZ  or XYZ ABC DEF, But it
> should not match when user query is like ABC or ABC XYZ
> I'm using Solr-6.6.0
> also using edismax parser
>
> I tried creating the custom field like
>
> <fieldType name="cust_shingle" class="solr.TextField"
> enableGraphQueries="false">
>     <analyzer type="index">
>       <tokenizer class="solr.KeywordTokenizerFactory"/>
>       <filter class="solr.PatternReplaceFilterFactory" pattern=" "
> replace="all" replacement=""/>
>       <filter class="solr.LowerCaseFilterFactory"/>
>     </analyzer>
>     <analyzer type="query">
>       <tokenizer class="solr.WhiteSpaceTokenizerFactory"/>
>       <filter class="solr.ShingleFilterFactory" minShingleSize="2"
> outputUnigrams="true" maxShingleSize="5" tokenSeparator=" "/>
>       <filter class="solr.PatternReplaceFilterFactory" pattern=" "
> replace="all" replacement=""/>
>       <filter class="solr.LowerCaseFilterFactory"/>
>     </analyzer>
>
>
> But it creating the synonyms query like (user query= 7 armour)
>
> +(((nameSearchNoSyn:7 nameSearchNoSyn:armour)~2)^9.0 | ((brandSearch:7
> brandSearch:armour)~2) |
>
>  ((nameSearch:7 nameSearch:armour)~2)^4.0 | (keywords:7 armour)^11.0 |
>
> ((descSearchNoSyn:7 descSearchNoSyn:armour)~2)^2.0 |
>
> *((Synonym(brandSearchQueryShingle:7 brandSearchQueryShingle:7armour)
> brandSearchQueryShingle:armour)~2)^10.0* |
>
> ((descriptionSearch:7 descriptionSearch:armour)~2) |
> (categoryKeywords:7 armour)^11.0) ((nameSearch:"7 armour"~5)^9.0 |
>
>  (brandSearch:"7 armour"~5)^8.0 | (descriptionSearch:"7
> armour"~5)^2.0) ((nameSearch:"7 armour")^9.0 |
>
> (descriptionSearch:"7 armour")^2.0)
>
>
> which again is not matching docs  ,
>
> Any idea how to boost the document if the user query contains exact
> value of that field
>
>
> my request handler is as
>
>
> <lst name="/browse">
> <str name="name">/browse</str>
> <str name="class">solr.SearchHandler</str>
> <lst name="defaults">
> <str name="echoParams">explicit</str>
> <str name="wt">velocity</str>
> <str name="indent">true</str>
> <str name="v.template">browse</str>
> <str name="v.layout">layout</str>
> <str name="title">Solritas</str>
> <str name="defType">edismax</str>
> <str name="qf">
> nameSearch^4 brandSearch *brandSearchQueryShingle*^10
> descriptionSearch categoryKeywords^11 keywords^11 nameSearchNoSyn^9
> descSearchNoSyn^2
> </str>
> <str name="ps">5</str>
> <str name="pf">
> nameSearch^9 brandSearch^8 descriptionSearch^2 categoryKeywords^10
> keywords^10
> </str>
> <str name="pf2">nameSearch^9 descriptionSearch^2</str>
> <str name="ps2">0</str>
> <str name="df">searchFields</str>
> <str name="mm">100%</str>
> <str name="q.alt">*:*</str>
> <str name="rows">10</str>
> <str name="fl">*,score</str>
> <str name="facet.mincount">1</str>
> <str name="facet.range.other">after</str>
> <str name="spellcheck">true</str>
> <str name="spellcheck.extendedResults">false</str>
> <str name="spellcheck.count">5</str>
> <str name="spellcheck.alternativeTermCount">2</str>
> <str name="spellcheck.maxResultsForSuggest">5</str>
> <str name="spellcheck.collate">true</str>
> <str name="spellcheck.collateExtendedResults">true</str>
> <str name="spellcheck.maxCollationTries">5</str>
> <str name="spellcheck.maxCollations">10</str>
> <str name="sow">*false*</str>
> </lst>
> <arr name="last-components">
> <str>spellcheck</str>
> </arr>
> </lst>
>
>
> Thanks,
>
> Aman Deep Singh
>

Re: Give boost only if entire value is present in Query

Posted by Susheel Kumar <su...@gmail.com>.
In general, the documents which has more or all terms matched against query
terms will be boosted higher per lucene tf/idf scoring.

So for document having ABC DEF queries like ABC DEF XYZ  or XYZ ABC DEF
will find a match(assuming q.op=AND)  and will be boosted higher compare to
documents with ABC or only DEF.

If you do not want match when user query is like ABC or ABC XYZ then you
have to use phrase queries or fields with keyword tokenizer etc.  and in
which case above queries will not work.

Thnx


On Mon, Jun 19, 2017 at 8:27 AM, Aman Deep Singh <am...@gmail.com>
wrote:

> Hi,
> I have a problem ,I need to give the boost to a particular field if and
> only if the query contains entire field value (String contains like
> feature).
> e.g. if Field value is ABC DEF
> It should match if user query is like ABC DEF XYZ  or XYZ ABC DEF, But it
> should not match when user query is like ABC or ABC XYZ
> I'm using Solr-6.6.0
> also using edismax parser
>
> I tried creating the custom field like
>
> <fieldType name="cust_shingle" class="solr.TextField"
> enableGraphQueries="false">
>     <analyzer type="index">
>       <tokenizer class="solr.KeywordTokenizerFactory"/>
>       <filter class="solr.PatternReplaceFilterFactory" pattern=" "
> replace="all" replacement=""/>
>       <filter class="solr.LowerCaseFilterFactory"/>
>     </analyzer>
>     <analyzer type="query">
>       <tokenizer class="solr.WhiteSpaceTokenizerFactory"/>
>       <filter class="solr.ShingleFilterFactory" minShingleSize="2"
> outputUnigrams="true" maxShingleSize="5" tokenSeparator=" "/>
>       <filter class="solr.PatternReplaceFilterFactory" pattern=" "
> replace="all" replacement=""/>
>       <filter class="solr.LowerCaseFilterFactory"/>
>     </analyzer>
>
>
> But it creating the synonyms query like (user query= 7 armour)
>
> +(((nameSearchNoSyn:7 nameSearchNoSyn:armour)~2)^9.0 | ((brandSearch:7
> brandSearch:armour)~2) |
>
>  ((nameSearch:7 nameSearch:armour)~2)^4.0 | (keywords:7 armour)^11.0 |
>
> ((descSearchNoSyn:7 descSearchNoSyn:armour)~2)^2.0 |
>
> *((Synonym(brandSearchQueryShingle:7 brandSearchQueryShingle:7armour)
> brandSearchQueryShingle:armour)~2)^10.0* |
>
> ((descriptionSearch:7 descriptionSearch:armour)~2) |
> (categoryKeywords:7 armour)^11.0) ((nameSearch:"7 armour"~5)^9.0 |
>
>  (brandSearch:"7 armour"~5)^8.0 | (descriptionSearch:"7
> armour"~5)^2.0) ((nameSearch:"7 armour")^9.0 |
>
> (descriptionSearch:"7 armour")^2.0)
>
>
> which again is not matching docs  ,
>
> Any idea how to boost the document if the user query contains exact
> value of that field
>
>
> my request handler is as
>
>
> <lst name="/browse">
> <str name="name">/browse</str>
> <str name="class">solr.SearchHandler</str>
> <lst name="defaults">
> <str name="echoParams">explicit</str>
> <str name="wt">velocity</str>
> <str name="indent">true</str>
> <str name="v.template">browse</str>
> <str name="v.layout">layout</str>
> <str name="title">Solritas</str>
> <str name="defType">edismax</str>
> <str name="qf">
> nameSearch^4 brandSearch *brandSearchQueryShingle*^10
> descriptionSearch categoryKeywords^11 keywords^11 nameSearchNoSyn^9
> descSearchNoSyn^2
> </str>
> <str name="ps">5</str>
> <str name="pf">
> nameSearch^9 brandSearch^8 descriptionSearch^2 categoryKeywords^10
> keywords^10
> </str>
> <str name="pf2">nameSearch^9 descriptionSearch^2</str>
> <str name="ps2">0</str>
> <str name="df">searchFields</str>
> <str name="mm">100%</str>
> <str name="q.alt">*:*</str>
> <str name="rows">10</str>
> <str name="fl">*,score</str>
> <str name="facet.mincount">1</str>
> <str name="facet.range.other">after</str>
> <str name="spellcheck">true</str>
> <str name="spellcheck.extendedResults">false</str>
> <str name="spellcheck.count">5</str>
> <str name="spellcheck.alternativeTermCount">2</str>
> <str name="spellcheck.maxResultsForSuggest">5</str>
> <str name="spellcheck.collate">true</str>
> <str name="spellcheck.collateExtendedResults">true</str>
> <str name="spellcheck.maxCollationTries">5</str>
> <str name="spellcheck.maxCollations">10</str>
> <str name="sow">*false*</str>
> </lst>
> <arr name="last-components">
> <str>spellcheck</str>
> </arr>
> </lst>
>
>
> Thanks,
>
> Aman Deep Singh
>