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 ?

Thanks for your help !

--
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/349babc4-5899-431e-9208-2bd6f9bea30f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You can use multiple terms in a should clause:

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

Ignore the comment about stackoverflow in the save, I learned about this
way to share elasticsearch queries through the example given there. Sorry
about that.

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 ?

Thanks for your help !

--
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/5bbd7090-1622-40ec-ab98-50c2925ac555%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Chris,

Thanks for your answer.
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 ?

Thanks for your help

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

Ignore the comment about stackoverflow in the save, I learned about this
way to share elasticsearch queries through the example given there. Sorry
about that.

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 ?

Thanks for your help !

--
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/26876144-7f0c-43e6-9576-1cb56aeaeb58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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,

Thanks for your answer.
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 ?

Thanks for your help

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

Ignore the comment about stackoverflow in the save, I learned about this
way to share elasticsearch queries through the example given there. Sorry
about that.

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 ?

Thanks for your help !

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/DQaDysus0zc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/26876144-7f0c-43e6-9576-1cb56aeaeb58%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/26876144-7f0c-43e6-9576-1cb56aeaeb58%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
For more options, visit https://groups.google.com/d/optout.

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

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

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,

Thanks for your answer.
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 ?

Thanks for your help

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

Ignore the comment about stackoverflow in the save, I learned about this
way to share elasticsearch queries through the example given there. Sorry
about that.

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 ?

Thanks for your help !

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/DQaDysus0zc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/26876144-7f0c-43e6-9576-1cb56aeaeb58%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/26876144-7f0c-43e6-9576-1cb56aeaeb58%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/ea316e70-4ce4-476e-9211-1c1038d687d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.