Terms on nested object and scoring

Hi,

I use a filter on a nested object to check idf the document get a least
one value like this :

"custom_filters_score": {
 "query" : { "term" : { "entity_type_id": 1 } },

  "filters" : [
   {
     "filter" : {
       "bool" :
       {
         "should" : [
           { "term" : { "country_iso3": "usa" } }
         ]
       }
     },
     "boost" : 3.0
   },

    {
     "filter" : {
       "nested" :
       {
         "path" : "profile_type.profile_roles",
         "query" : {
           "filtered" : {
             "query": { "match_all": {}},
             "filter" :
             {
               "bool" :
               {
                 "must" :
                 [
                   {"terms": {"profile_type.profile_roles.role_id": [20,

23,5]}},
{"terms": {
"profile_type.profile_roles.skills.skill_id": [32,34,25,6,38]}}
]
}
}
}
}
}
},
"boost" : 2.0
}

  ],
 "score_mode" : "total"

}

Here "profile_roles" is a nested object containing an array of "roles"

It works great , but in my results some document match all
profile_type.profile_roles.role_id ( 20 , 23 and 5 ) and all
profile_type.profile_roles.skills.skill_id while some other match only one
role.
So i 'm looking for a way of giving a highest score to the document that
have more match , the one have 20 , 23 and 5 should have higher score than
the one who only have role_id 5.
Is there any solution for that ?

Thanks

--

Hello Samuel,

If you want to have higher score on the role_id, you can specify a
boost for that terms query in particular. Something like:

"bool" : {
"must" : [
{
"terms": {
"profile_type.profile_roles.role_id": [20,23,5],
"boost" : 5.0
}
},
{"terms": {"profile_type.profile_roles.skills.skill_id":
[32,34,25,6,38]}}
]
}

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 17, 2012 at 6:17 PM, samuel merlet samuel.merlet@gmail.com wrote:

Hi,

I use a filter on a nested object to check idf the document get a least one
value like this :

"custom_filters_score": {
 "query" : { "term" : { "entity_type_id": 1 } },

  "filters" : [
   {
     "filter" : {
       "bool" :
       {
         "should" : [
           { "term" : { "country_iso3": "usa" } }
         ]
       }
     },
     "boost" : 3.0
   },

    {
     "filter" : {
       "nested" :
       {
         "path" : "profile_type.profile_roles",
         "query" : {
           "filtered" : {
             "query": { "match_all": {}},
             "filter" :
             {
               "bool" :
               {
                 "must" :
                 [
                   {"terms": {"profile_type.profile_roles.role_id":

[20,23,5]}},
{"terms":
{"profile_type.profile_roles.skills.skill_id": [32,34,25,6,38]}}
]
}
}
}
}
}
},
"boost" : 2.0
}

  ],
 "score_mode" : "total"

}

Here "profile_roles" is a nested object containing an array of "roles"

It works great , but in my results some document match all
profile_type.profile_roles.role_id ( 20 , 23 and 5 ) and all
profile_type.profile_roles.skills.skill_id while some other match only one
role.
So i 'm looking for a way of giving a highest score to the document that
have more match , the one have 20 , 23 and 5 should have higher score than
the one who only have role_id 5.
Is there any solution for that ?

Thanks

--

--

Hi,

No this doesn't works, "terms" filter doesn't support boost. And i don't
want to boost a filter , i'm looking for a way to give a higher score to
the document that have more match over the terms list

thanks

On Wednesday, October 17, 2012 5:46:13 PM UTC+2, Radu Gheorghe wrote:

Hello Samuel,

If you want to have higher score on the role_id, you can specify a
boost for that terms query in particular. Something like:

"bool" : {
"must" : [
{
"terms": {
"profile_type.profile_roles.role_id": [20,23,5],
"boost" : 5.0
}
},
{"terms": {"profile_type.profile_roles.skills.skill_id":
[32,34,25,6,38]}}
]
}

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 17, 2012 at 6:17 PM, samuel merlet <samuel...@gmail.com<javascript:>>
wrote:

Hi,

I use a filter on a nested object to check idf the document get a least
one
value like this :

"custom_filters_score": { 
 "query" : { "term" : { "entity_type_id": 1 } }, 

  "filters" : [ 
   { 
     "filter" : { 
       "bool" : 
       { 
         "should" : [ 
           { "term" : { "country_iso3": "usa" } } 
         ] 
       } 
     }, 
     "boost" : 3.0 
   }, 

    { 
     "filter" : { 
       "nested" : 
       { 
         "path" : "profile_type.profile_roles", 
         "query" : { 
           "filtered" : { 
             "query": { "match_all": {}}, 
             "filter" : 
             { 
               "bool" : 
               { 
                 "must" : 
                 [ 
                   {"terms": {"profile_type.profile_roles.role_id": 

[20,23,5]}},
{"terms":
{"profile_type.profile_roles.skills.skill_id": [32,34,25,6,38]}}
]
}
}
}
}
}
},
"boost" : 2.0
}

  ], 
 "score_mode" : "total" 

}

Here "profile_roles" is a nested object containing an array of "roles"

It works great , but in my results some document match all
profile_type.profile_roles.role_id ( 20 , 23 and 5 ) and all
profile_type.profile_roles.skills.skill_id while some other match only
one
role.
So i 'm looking for a way of giving a highest score to the document that
have more match , the one have 20 , 23 and 5 should have higher score
than
the one who only have role_id 5.
Is there any solution for that ?

Thanks

--

--

Hello Samuel,

Sorry, I completely missed that you had a filter and not a query
there. The only solution I see here is to move those terms filters as
term queries, so you can boost on them.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 17, 2012 at 7:04 PM, samuel merlet samuel.merlet@gmail.com wrote:

Hi,

No this doesn't works, "terms" filter doesn't support boost. And i don't
want to boost a filter , i'm looking for a way to give a higher score to
the document that have more match over the terms list

thanks

On Wednesday, October 17, 2012 5:46:13 PM UTC+2, Radu Gheorghe wrote:

Hello Samuel,

If you want to have higher score on the role_id, you can specify a
boost for that terms query in particular. Something like:

"bool" : {
"must" : [
{
"terms": {
"profile_type.profile_roles.role_id": [20,23,5],
"boost" : 5.0
}
},
{"terms": {"profile_type.profile_roles.skills.skill_id":
[32,34,25,6,38]}}
]
}

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 17, 2012 at 6:17 PM, samuel merlet samuel...@gmail.com
wrote:

Hi,

I use a filter on a nested object to check idf the document get a least
one
value like this :

"custom_filters_score": {
 "query" : { "term" : { "entity_type_id": 1 } },

  "filters" : [
   {
     "filter" : {
       "bool" :
       {
         "should" : [
           { "term" : { "country_iso3": "usa" } }
         ]
       }
     },
     "boost" : 3.0
   },

    {
     "filter" : {
       "nested" :
       {
         "path" : "profile_type.profile_roles",
         "query" : {
           "filtered" : {
             "query": { "match_all": {}},
             "filter" :
             {
               "bool" :
               {
                 "must" :
                 [
                   {"terms": {"profile_type.profile_roles.role_id":

[20,23,5]}},
{"terms":
{"profile_type.profile_roles.skills.skill_id": [32,34,25,6,38]}}
]
}
}
}
}
}
},
"boost" : 2.0
}

  ],
 "score_mode" : "total"

}

Here "profile_roles" is a nested object containing an array of "roles"

It works great , but in my results some document match all
profile_type.profile_roles.role_id ( 20 , 23 and 5 ) and all
profile_type.profile_roles.skills.skill_id while some other match only
one
role.
So i 'm looking for a way of giving a highest score to the document that
have more match , the one have 20 , 23 and 5 should have higher score
than
the one who only have role_id 5.
Is there any solution for that ?

Thanks

--

--

--