Boolean query with nested document

Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out the
complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id" : "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" : "L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" : "MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

Yes, you can, unless you sue nested mapping (not sure if thats what you
meant), in which case, you need to wrap the specific field in nested query.

On Wed, May 30, 2012 at 9:43 PM, Mohit Anchlia mohitanchlia@gmail.comwrote:

Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out the
complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id" : "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" : "L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" : "MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

On Sun, Jun 3, 2012 at 2:16 AM, Shay Banon kimchy@gmail.com wrote:

Yes, you can, unless you sue nested mapping (not sure if thats what you
meant), in which case, you need to wrap the specific field in nested query.

Could you please give me a short example so that I can visualize what you
mean?

On Wed, May 30, 2012 at 9:43 PM, Mohit Anchlia mohitanchlia@gmail.comwrote:

Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out the
complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id http://setmodel.forms.id/" :
"40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" : "L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" : "MRS1"
}
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

On Sun, Jun 3, 2012 at 9:45 AM, Mohit Anchlia mohitanchlia@gmail.comwrote:

On Sun, Jun 3, 2012 at 2:16 AM, Shay Banon kimchy@gmail.com wrote:

Yes, you can, unless you sue nested mapping (not sure if thats what you
meant), in which case, you need to wrap the specific field in nested query.

Could you please give me a short example so that I can visualize what you
mean?

Is there any chance you could give me some pointers here?

On Wed, May 30, 2012 at 9:43 PM, Mohit Anchlia mohitanchlia@gmail.comwrote:

Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out the
complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id http://setmodel.forms.id/"
: "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" : "L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" :
"MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

    Could you please give me a short example so that I can
    visualize what you mean?

Is there any chance you could give me some pointers here?

Have you looked at the examples in the docs? What have you tried? What
didn't work?

On Thu, Jun 7, 2012 at 7:13 AM, Clinton Gormley clint@traveljury.comwrote:

    Could you please give me a short example so that I can
    visualize what you mean?

Is there any chance you could give me some pointers here?

Have you looked at the examples in the docs? What have you tried? What
didn't work?

But with related to which topic. I don't understand what exactly Shay was
referring to? Is it related to Mapping? if yes then which type of mapping?
I've tried nested but didn't seem to work.

But with related to which topic. I don't understand what exactly Shay
was referring to? Is it related to Mapping? if yes then which type of
mapping? I've tried nested but didn't seem to work.

it's really difficult to point you in the right direction without
knowing exactly what you're trying to do and what didn't work.

Have a read of this page Elasticsearch Platform — Find real-time answers at scale | Elastic which gives
advice for how to ask a good question. The key is: We're all short on
time, so make it easy for people to answer.

clint

On Thu, Jun 7, 2012 at 7:27 AM, Clinton Gormley clint@traveljury.comwrote:

But with related to which topic. I don't understand what exactly Shay
was referring to? Is it related to Mapping? if yes then which type of
mapping? I've tried nested but didn't seem to work.

it's really difficult to point you in the right direction without
knowing exactly what you're trying to do and what didn't work.

Have a read of this page Elasticsearch Platform — Find real-time answers at scale | Elastic which gives
advice for how to ask a good question. The key is: We're all short on
time, so make it easy for people to answer.

clint

Did you get chance to look at my initial post? Is this not clear enough? If
not then what's not clear in this description.


Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out the
complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id" : "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" : "L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" : "MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

Did you get chance to look at my initial post? Is this not clear
enough? If not then what's not clear in this description.

I looked at your original post. Shay's response was "not sure if that is
what you meant", which implies that the post isn't clear.

You use the term "nested" but then you don't use nested queries in your
example.

So reposting the same post doesn't make it any clearer. Read this

clint


Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out
the complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id" : "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" :
"L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" :
"MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

On Thu, Jun 7, 2012 at 7:41 AM, Clinton Gormley clint@traveljury.comwrote:

Did you get chance to look at my initial post? Is this not clear
enough? If not then what's not clear in this description.

I looked at your original post. Shay's response was "not sure if that is
what you meant", which implies that the post isn't clear.

You use the term "nested" but then you don't use nested queries in your
example.

So reposting the same post doesn't make it any clearer. Read this
Elasticsearch Platform — Find real-time answers at scale | Elastic

Well that is what I am asking :slight_smile: What do I need to do to make it is such
that I can say fields.MSR11 instead of giving the full path.
clint


Currently to search nested fields I do something like:

Is it possible to somehow say "fields.MRSSN1" instead of listing out
the complete Path like "setModel.forms.forms.fields"?

curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
"query" : {
"bool" : {
"must" : {
"term" : { "setModel.forms.id http://setmodel.forms.id/"
: "40" }
},
"should" : [
{
"field" : { "setModel.forms.forms.fields.L31A" :
"L31" }
},
{
"field" : { "setModel.forms.forms.fields.MRSSN1" :
"MRS1" }
}
],
"minimum_number_should_match" : 2,
"boost" : 1.0
}
}
}'

Well that is what I am asking :slight_smile: What do I need to do to make it is
such that I can say fields.MSR11 instead of giving the full path.
clint

Nothing. It just works.

I can't guess what you're doing wrong, so if you're not going to give an
example showing what you tried and how it doesn't work, then I don't
have the time to help you.

    > ----
    >
    > Currently to search nested fields I do something like:
    >
    > Is it possible to somehow say "fields.MRSSN1" instead of
    listing out
    > the complete Path like "setModel.forms.forms.fields"?
    >
    >  curl -XGET 'http://dslg1:9200/forms1/object/_search' -d '{
    >   "query" : {
    >     "bool" : {
    >         "must" : {
    >             "term" : { "setModel.forms.id" : "40" }
    >         },
    >         "should" : [
    >             {
    >                 "field" :
    { "setModel.forms.forms.fields.L31A" :
    > "L31" }
    >             },
    >             {
    >                 "field" :
    { "setModel.forms.forms.fields.MRSSN1" :
    > "MRS1" }
    >             }
    >         ],
    >         "minimum_number_should_match" : 2,
    >         "boost" : 1.0
    >     }
    >   }
    > }'
    >