# Word count score

Hi !

I'd like to calculate the score of a query as the number of matched
wordsas, as do sphinx's "word_count".
For example, if the query is "word1 word2 word3",
then for each document, if the title contains word1, his score will be 1,
if it contains word1 and word2 the score will be 2, and the score will be 3
if it contains the 3 words.

How could I do that ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.

You can use multiple terms in a should clause:

https://www.found.no/play/gist/905a2a067dd79593e8f5

way to share elasticsearch queries through the example given there. Sorry

There may be simpler ways, but this way works pretty effectively.

On Wednesday, February 25, 2015 at 11:33:55 AM UTC-5, Christophe Rosko
wrote:

Hi !

I'd like to calculate the score of a query as the number of matched
wordsas, as do sphinx's "word_count".
For example, if the query is "word1 word2 word3",
then for each document, if the title contains word1, his score will be 1,
if it contains word1 and word2 the score will be 2, and the score will be 3
if it contains the 3 words.

How could I do that ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.

Hi Chris,

This is not exactly the behaviour I expected.
What i'd like to have on your example is :
=> "Microscopic examination of specimen from bacteria" has a score equals
to 3 because it's matching 3 words
=> "Bacteria specimen" has a score equals to 2 because it's matching 2 words
=> etc

How can I adapt your query to get this kind of score ?

Le jeudi 26 février 2015 04:45:52 UTC+1, Chris Pall a écrit :

You can use multiple terms in a should clause:

https://www.found.no/play/gist/905a2a067dd79593e8f5

way to share elasticsearch queries through the example given there. Sorry

There may be simpler ways, but this way works pretty effectively.

On Wednesday, February 25, 2015 at 11:33:55 AM UTC-5, Christophe Rosko
wrote:

Hi !

I'd like to calculate the score of a query as the number of matched
wordsas, as do sphinx's "word_count".
For example, if the query is "word1 word2 word3",
then for each document, if the title contains word1, his score will be 1,
if it contains word1 and word2 the score will be 2, and the score will be 3
if it contains the 3 words.

How could I do that ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.

I'm not exactly sure how to get it to set exactly a particular score. I
played around with constant_score for a minute or two but had to move on.

I was hoping that just getting the relevance score correct would suit your
purposes -- good luck!

On Thu, Feb 26, 2015 at 4:05 AM, Christophe Rosko christophe@digiteka.com
wrote:

Hi Chris,

This is not exactly the behaviour I expected.
What i'd like to have on your example is :
=> "Microscopic examination of specimen from bacteria" has a score equals
to 3 because it's matching 3 words
=> "Bacteria specimen" has a score equals to 2 because it's matching 2
words
=> etc

How can I adapt your query to get this kind of score ?

Le jeudi 26 février 2015 04:45:52 UTC+1, Chris Pall a écrit :

You can use multiple terms in a should clause:

https://www.found.no/play/gist/905a2a067dd79593e8f5

way to share elasticsearch queries through the example given there. Sorry

There may be simpler ways, but this way works pretty effectively.

On Wednesday, February 25, 2015 at 11:33:55 AM UTC-5, Christophe Rosko
wrote:

Hi !

I'd like to calculate the score of a query as the number of matched
wordsas, as do sphinx's "word_count".
For example, if the query is "word1 word2 word3",
then for each document, if the title contains word1, his score will be
1, if it contains word1 and word2 the score will be 2, and the score will
be 3 if it contains the 3 words.

How could I do that ?

--
You received this message because you are subscribed to a topic in the
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAAnL-vDnp-35Op7PAstykha6QO7%3DYmhsR84JmgHV2VCxCYz5Bg%40mail.gmail.com.

Thanks for your help anyway Chris
I'll keep trying and let you know if I find a solution.

And if anyone here know how to do that, please share

Le jeudi 26 février 2015 15:03:30 UTC+1, Chris Pall a écrit :

I'm not exactly sure how to get it to set exactly a particular score. I
played around with constant_score for a minute or two but had to move on.

I was hoping that just getting the relevance score correct would suit your
purposes -- good luck!

On Thu, Feb 26, 2015 at 4:05 AM, Christophe Rosko <chris...@digiteka.com
<javascript:>> wrote:

Hi Chris,

This is not exactly the behaviour I expected.
What i'd like to have on your example is :
=> "Microscopic examination of specimen from bacteria" has a score equals
to 3 because it's matching 3 words
=> "Bacteria specimen" has a score equals to 2 because it's matching 2
words
=> etc

How can I adapt your query to get this kind of score ?

Le jeudi 26 février 2015 04:45:52 UTC+1, Chris Pall a écrit :

You can use multiple terms in a should clause:

https://www.found.no/play/gist/905a2a067dd79593e8f5

way to share elasticsearch queries through the example given there. Sorry

There may be simpler ways, but this way works pretty effectively.

On Wednesday, February 25, 2015 at 11:33:55 AM UTC-5, Christophe Rosko
wrote:

Hi !

I'd like to calculate the score of a query as the number of matched
wordsas, as do sphinx's "word_count".
For example, if the query is "word1 word2 word3",
then for each document, if the title contains word1, his score will be
1, if it contains word1 and word2 the score will be 2, and the score will
be 3 if it contains the 3 words.

How could I do that ?

--
You received this message because you are subscribed to a topic in the
To unsubscribe from this topic, visit