Score depending on position in the term on the field

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Score depending on position in the term on the field

Nikolay Chankov
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE 'http://localhost:9200/test_search'
curl -XPUT 'http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT 'http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT 'http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT 'http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET 'http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c69d8a86-f991-4f00-a315-ff56fc075bee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Johan Rask
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2e9ae53d-0bb3-4d56-93b2-f62c95fe93fb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Nikolay Chankov
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d2d79908-0131-4220-941c-eb31e51b9667%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Johan Rask
Hi again,

Can you explain more what you are trying to accomplish?

I "think" that the only way you can solve this is to split into multiple fields and
then boost individual fields in your query. Not sure if thats possible for you.

/Johan

Den torsdagen den 23:e januari 2014 kl. 09:44:02 UTC+1 skrev Nikolay Chankov:
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field <a href="http://user.name" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;">user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7d7a5a5d-cc7f-4035-b5fb-a558cd71559f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Nikolay Chankov
Hi Johan,

I've already saw this suggestion, but it's not really useful for me, since in the index there are various document with different types. For example, I have users, but also I have venues and events, last two had only name, while user could have two names.

In general I am trying to build an autosuggest feature on a site and when you start typing 'Joh' the suggestions will be first users starting with 'Joh', but there could be some venues starting with 'Joh' string as well, so as much you type, the more concrete results you will have, but I am also reading about suggesters, and probably I will implement a solution which will be more like Google autosuggest rather displaying the first few results of the search itself.

I've seen also text scoring in scripts which could be a solution as well.

I just wanted to ask if there is something like common way of score the position of the term in a field, but obviously there is no such way. :)

Thanks for the help



On Thursday, January 23, 2014 9:36:47 AM UTC, Johan Rask wrote:
Hi again,

Can you explain more what you are trying to accomplish?

I "think" that the only way you can solve this is to split into multiple fields and
then boost individual fields in your query. Not sure if thats possible for you.

/Johan

Den torsdagen den 23:e januari 2014 kl. 09:44:02 UTC+1 skrev Nikolay Chankov:
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field <a href="http://user.name" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;">user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6c5871a3-7421-4626-86c6-ca92afce3534%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Nikolay Chankov
Just checked the Facebook suggestion style and I would imagine something like, this, When you start typing terms which start with the phrase/word are in the top, while the terms which just contain the phrase/word, are at the bottom. But I could be wrong that that the order is this way :)


On Thursday, January 23, 2014 10:08:25 AM UTC, Nikolay Chankov wrote:
Hi Johan,

I've already saw this suggestion, but it's not really useful for me, since in the index there are various document with different types. For example, I have users, but also I have venues and events, last two had only name, while user could have two names.

In general I am trying to build an autosuggest feature on a site and when you start typing 'Joh' the suggestions will be first users starting with 'Joh', but there could be some venues starting with 'Joh' string as well, so as much you type, the more concrete results you will have, but I am also reading about suggesters, and probably I will implement a solution which will be more like Google autosuggest rather displaying the first few results of the search itself.

I've seen also <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-advanced-scripting.html" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;">text scoring in scripts which could be a solution as well.

I just wanted to ask if there is something like common way of score the position of the term in a field, but obviously there is no such way. :)

Thanks for the help



On Thursday, January 23, 2014 9:36:47 AM UTC, Johan Rask wrote:
Hi again,

Can you explain more what you are trying to accomplish?

I "think" that the only way you can solve this is to split into multiple fields and
then boost individual fields in your query. Not sure if thats possible for you.

/Johan

Den torsdagen den 23:e januari 2014 kl. 09:44:02 UTC+1 skrev Nikolay Chankov:
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field <a href="http://user.name" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;">user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2f1ea0ed-a0f8-4b38-b483-3b223d4a2899%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

Nikolay Chankov
Well, it's really strange, that position is not encountered, since with many results and especially data with lot of similarities (user names) doesn't get sorted also by string position somehow.

Anyone to share how do they make autocomplete? Feeling really stupid :(

On Thursday, January 23, 2014 10:56:30 AM UTC, Nikolay Chankov wrote:
Just checked the Facebook suggestion style and I would imagine something like, this, When you start typing terms which start with the phrase/word are in the top, while the terms which just contain the phrase/word, are at the bottom. But I could be wrong that that the order is this way :)


On Thursday, January 23, 2014 10:08:25 AM UTC, Nikolay Chankov wrote:
Hi Johan,

I've already saw this suggestion, but it's not really useful for me, since in the index there are various document with different types. For example, I have users, but also I have venues and events, last two had only name, while user could have two names.

In general I am trying to build an autosuggest feature on a site and when you start typing 'Joh' the suggestions will be first users starting with 'Joh', but there could be some venues starting with 'Joh' string as well, so as much you type, the more concrete results you will have, but I am also reading about suggesters, and probably I will implement a solution which will be more like Google autosuggest rather displaying the first few results of the search itself.

I've seen also <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-advanced-scripting.html" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;">text scoring in scripts which could be a solution as well.

I just wanted to ask if there is something like common way of score the position of the term in a field, but obviously there is no such way. :)

Thanks for the help



On Thursday, January 23, 2014 9:36:47 AM UTC, Johan Rask wrote:
Hi again,

Can you explain more what you are trying to accomplish?

I "think" that the only way you can solve this is to split into multiple fields and
then boost individual fields in your query. Not sure if thats possible for you.

/Johan

Den torsdagen den 23:e januari 2014 kl. 09:44:02 UTC+1 skrev Nikolay Chankov:
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field <a href="http://user.name" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;">user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d4632bdc-c200-4322-a0d2-574e629f2206%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Score depending on position in the term on the field

simonw-2
maybe this is interesting in your situation?

http://www.elasticsearch.org/blog/you-complete-me/

simon

On Thursday, January 23, 2014 4:15:05 PM UTC+1, Nikolay Chankov wrote:
Well, it's really strange, that position is not encountered, since with many results and especially data with lot of similarities (user names) doesn't get sorted also by string position somehow.

Anyone to share how do they make autocomplete? Feeling really stupid :(

On Thursday, January 23, 2014 10:56:30 AM UTC, Nikolay Chankov wrote:
Just checked the Facebook suggestion style and I would imagine something like, this, When you start typing terms which start with the phrase/word are in the top, while the terms which just contain the phrase/word, are at the bottom. But I could be wrong that that the order is this way :)


On Thursday, January 23, 2014 10:08:25 AM UTC, Nikolay Chankov wrote:
Hi Johan,

I've already saw this suggestion, but it's not really useful for me, since in the index there are various document with different types. For example, I have users, but also I have venues and events, last two had only name, while user could have two names.

In general I am trying to build an autosuggest feature on a site and when you start typing 'Joh' the suggestions will be first users starting with 'Joh', but there could be some venues starting with 'Joh' string as well, so as much you type, the more concrete results you will have, but I am also reading about suggesters, and probably I will implement a solution which will be more like Google autosuggest rather displaying the first few results of the search itself.

I've seen also <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-advanced-scripting.html" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fmaster%2Fmodules-advanced-scripting.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEGgIoGXbg0PMbNp-DatggQE3CDvA';return true;">text scoring in scripts which could be a solution as well.

I just wanted to ask if there is something like common way of score the position of the term in a field, but obviously there is no such way. :)

Thanks for the help



On Thursday, January 23, 2014 9:36:47 AM UTC, Johan Rask wrote:
Hi again,

Can you explain more what you are trying to accomplish?

I "think" that the only way you can solve this is to split into multiple fields and
then boost individual fields in your query. Not sure if thats possible for you.

/Johan

Den torsdagen den 23:e januari 2014 kl. 09:44:02 UTC+1 skrev Nikolay Chankov:
Hi Johan,

thanks for the reply

I would agree that it's ok, if I am searching for common term, like 'venue', 'club' or 'bar', but when it comes to User names, it make sense to score the position in the field too, because when you search in field <a href="http://user.name" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fuser.name\46sa\75D\46sntz\0751\46usg\75AFQjCNFu0SPm6QpHZ5742pOucYZFgv7vIQ';return true;">user.name, and type 'Jo' you would expect first to see users with first name Joe, Johan, John, rather than having users with Jo in the family.

And especially when you search for user name field you don't expect to have more occurrence of the name  in that field.



On Wednesday, January 22, 2014 9:30:19 PM UTC, Johan Rask wrote:
Lucene will calculate you score based on a scoring formula. I am pretty sure that the location of the word is not part of this formula but rather how common the
word is in your sentence. I.e multiple occurences of 'venue' should increase scoring and adding other words to your sentence should decrease the scoring.

Hope this helps, I am pretty sure there is detailed info about this in the lucene docs. 

Kind regards /Johan

Den onsdagen den 22:e januari 2014 kl. 13:10:00 UTC+1 skrev Nikolay Chankov:
I am playing with elasticsearch so far, and i noticed something:

If I search for a word in a string, the _score is equal no matter where is placed the word. Here I have prepared a test case:

curl -XDELETE '<a href="http://localhost:9200/test_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search\46sa\75D\46sntz\0751\46usg\75AFQjCNFjV8D1myrCQ5EL1GytcaI1W7SDog';return true;">http://localhost:9200/test_search'
curl -XPUT '<a href="http://localhost:9200/test_search/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHHBvo2DLnIlmVASM6ApikQU7ZuYA';return true;">http://localhost:9200/test_search/' -d '
{
    "mappings" : {
        "test_record" : {
            "properties" : {
                "name" : { 
                    "type" : "string"
                }
            }
        }
    }
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/1" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F1\46sa\75D\46sntz\0751\46usg\75AFQjCNF7tMfYAnFeoUkwE_OJSkd0UnnxvQ';return true;">http://localhost:9200/test_search/test_record/1' -d '{
    "name" : "is the name Venue of that one"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/2" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F2\46sa\75D\46sntz\0751\46usg\75AFQjCNF4hP4r50sO1weIOB78TzJRh2AJPQ';return true;">http://localhost:9200/test_search/test_record/2' -d '{
    "name" : "is the name of that one Venue"
}'

curl -XPUT '<a href="http://localhost:9200/test_search/test_record/3" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2Ftest_record%2F3\46sa\75D\46sntz\0751\46usg\75AFQjCNEjRFZtQkGf0ruJyU4Y16oJWEsZoQ';return true;">http://localhost:9200/test_search/test_record/3' -d '{
    "name" : "Venue is the name of that one"
}'

curl -XGET '<a href="http://localhost:9200/test_search/_search" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flocalhost%3A9200%2Ftest_search%2F_search\46sa\75D\46sntz\0751\46usg\75AFQjCNHYo9uUwovJtNuqOgjIlm87uUdXag';return true;">http://localhost:9200/test_search/_search' -d '{
    "query": {
        "bool": {
            "must": [ ],
            "must_not": [ ],
            "should": [
                {
                    "query_string" : {
                        "default_field": "_all",
                        "query" : "venue"
                    }
                }
            ]
        }
    },
    "from": 0,
    "size": 10
}'

The question is: how to have different score based on the position of the word 'venue' in the test. When I search I would expect results to be ordered 3,1,2 while now they are as they are inserted ,1,2,3.

Any hint will be much appreciated

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8cb8fd26-cc4d-4f26-a7cb-b7c6ef5048dc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.