A little help in a "Complex query"

Hi dear ES community

I am trying to achive some query functionallity from ES , and not sure how
to do that right.

So i have a large product index.

And I would like to query for :

  1. Query for products that have "sharp televisions" in "name"
  2. Then i would like lucene to order the results from 1 by having also
    "sharp televisions" in their "manufacturer" field

I looks to me like a nested query , get all the results from 1 and apply
the function from 2 on them.

So for instance here is the clause from 1 :

{
"query": {
"query_string": {
"query": "sharp televisions",
"default_field": "name",
"default_operator": "and"
}
}
}

And that clause would be from 2 :
{
"custom_boost_factor": {
"query": {
"query_string": {
"query": "sharp televisions",
"fields": [
"seller",
"manufacturer"
],
"default_operator": "or"
}
},
"boost_factor": 3.0
}
}

Now how the hell i create a nested query with these 2 clauses ?

--

Hi Roman,

What not using a MatchQuery on each field and use a boost factor for the Match
query on manufacturer?

Does it help?
David

Le 6 décembre 2012 à 10:42, Roman Kournjaev kournjaev@gmail.com a écrit :

Hi dear ES community

I am trying to achive some query functionallity from ES , and not sure how to
do that right.

So i have a large product index.

And I would like to query for :

1. Query for products that have "sharp televisions" in "name"
2. Then i would like lucene to order the results from 1 by having also

"sharp televisions" in their "manufacturer" field

I looks to me like a nested query , get all the results from 1 and apply the
function from 2 on them.

So for instance here is the clause from 1 :

{
"query": {
"query_string": {
"query": "sharp televisions",
"default_field": "name",
"default_operator": "and"
}
}
}

And that clause would be from 2 :
{
"custom_boost_factor" : {
"query" : {
"query_string" : {
"query" : "sharp televisions" ,
"fields" : [
"seller" ,
"manufacturer"
],
"default_operator" : "or"
}
},
"boost_factor" : 3.0
}
}

Now how the hell i create a nested query with these 2 clauses ?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Hi David

Not sure it will return me the results I need.

If the 2 clauses are in the same level , and in the second level i have the
operator set to "OR". I will get results , (even if they are not high
rated) , that have for instance "sharp" in the manufacturer but are not
televisions.
Is there an opiton to use a nested query ?

Roman

On Thursday, December 6, 2012 12:12:25 PM UTC+2, David Pilato wrote:

Hi Roman,

What not using a MatchQuery on each field and use a boost factor for the
Match query on manufacturer?

Does it help?
David

Le 6 décembre 2012 à 10:42, Roman Kournjaev <kour...@gmail.com<javascript:>>
a écrit :

Hi dear ES community

I am trying to achive some query functionallity from ES , and not sure
how to do that right.

So i have a large product index.

And I would like to query for :

  1. Query for products that have "sharp televisions" in "name"
  2. Then i would like lucene to order the results from 1 by having also
    "sharp televisions" in their "manufacturer" field

I looks to me like a nested query , get all the results from 1 and apply
the function from 2 on them.

So for instance here is the clause from 1 :

{
"query": {
"query_string": {
"query": "sharp televisions",
"default_field": "name",
"default_operator": "and"
}
}
}

And that clause would be from 2 :
{
"custom_boost_factor" : {
"query" : {
"query_string" : {
"query" : "sharp televisions" ,
"fields" : [
"seller" ,
"manufacturer"
],
"default_operator" : "or"
}
},
"boost_factor" : 3.0
}
}

Now how the hell i create a nested query with these 2 clauses ?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

If I understood you requirements correctly, you should be able to build
such query by using the custom_filters_scorehttp://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.htmlquery with the first clause as a query and the second clause as one of the
filters.

On Thursday, December 6, 2012 5:18:11 AM UTC-5, Roman Kournjaev wrote:

Hi David

Not sure it will return me the results I need.

If the 2 clauses are in the same level , and in the second level i have
the operator set to "OR". I will get results , (even if they are not high
rated) , that have for instance "sharp" in the manufacturer but are not
televisions.
Is there an opiton to use a nested query ?

Roman

On Thursday, December 6, 2012 12:12:25 PM UTC+2, David Pilato wrote:

Hi Roman,

What not using a MatchQuery on each field and use a boost factor for the
Match query on manufacturer?

Does it help?
David

Le 6 décembre 2012 à 10:42, Roman Kournjaev kour...@gmail.com a
écrit :

Hi dear ES community

I am trying to achive some query functionallity from ES , and not sure
how to do that right.

So i have a large product index.

And I would like to query for :

  1. Query for products that have "sharp televisions" in "name"
  2. Then i would like lucene to order the results from 1 by having
    also "sharp televisions" in their "manufacturer" field

I looks to me like a nested query , get all the results from 1 and
apply the function from 2 on them.

So for instance here is the clause from 1 :

{
"query": {
"query_string": {
"query": "sharp televisions",
"default_field": "name",
"default_operator": "and"
}
}
}

And that clause would be from 2 :
{
"custom_boost_factor" : {
"query" : {
"query_string" : {
"query" : "sharp televisions" ,
"fields" : [
"seller" ,
"manufacturer"
],
"default_operator" : "or"
}
},
"boost_factor" : 3.0
}
}

Now how the hell i create a nested query with these 2 clauses ?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Thanks Igor , thats exactly what i need.

On Friday, December 7, 2012 6:35:27 AM UTC+2, Igor Motov wrote:

If I understood you requirements correctly, you should be able to build
such query by using the custom_filters_scorehttp://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.htmlquery with the first clause as a query and the second clause as one of the
filters.

On Thursday, December 6, 2012 5:18:11 AM UTC-5, Roman Kournjaev wrote:

Hi David

Not sure it will return me the results I need.

If the 2 clauses are in the same level , and in the second level i have
the operator set to "OR". I will get results , (even if they are not high
rated) , that have for instance "sharp" in the manufacturer but are not
televisions.
Is there an opiton to use a nested query ?

Roman

On Thursday, December 6, 2012 12:12:25 PM UTC+2, David Pilato wrote:

Hi Roman,

What not using a MatchQuery on each field and use a boost factor for
the Match query on manufacturer?

Does it help?
David

Le 6 décembre 2012 à 10:42, Roman Kournjaev kour...@gmail.com a
écrit :

Hi dear ES community

I am trying to achive some query functionallity from ES , and not sure
how to do that right.

So i have a large product index.

And I would like to query for :

  1. Query for products that have "sharp televisions" in "name"
  2. Then i would like lucene to order the results from 1 by having
    also "sharp televisions" in their "manufacturer" field

I looks to me like a nested query , get all the results from 1 and
apply the function from 2 on them.

So for instance here is the clause from 1 :

{
"query": {
"query_string": {
"query": "sharp televisions",
"default_field": "name",
"default_operator": "and"
}
}
}

And that clause would be from 2 :
{
"custom_boost_factor" : {
"query" : {
"query_string" : {
"query" : "sharp televisions" ,
"fields" : [
"seller" ,
"manufacturer"
],
"default_operator" : "or"
}
},
"boost_factor" : 3.0
}
}

Now how the hell i create a nested query with these 2 clauses ?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--