Newbie question on searching

Hi:

For some reason I am having a lot of trouble wrapping my brain around
the Elasticsearch query capability.

I am trying to match for multiple values in specified fields

Here is what I am trying, but it returns no records:

 {
            "query": {
                    "filtered": {
                            "query" : { "match_all" : {} },
                            "filter" : {
                                    "or" : [
                                            { "term" : { "field1":

"value1" }},
{ "term" : { "field2":
"value1" }},
{ "term" : { "field1":
"value2" }},
{ "term" : { "field2":
"value2" }}
]
}
}
}
}

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

Hi Jim,

Any chance that you could gist a full curl recreation to understand your concern?
See http://www.elasticsearch.org/help/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 26 novembre 2013 at 00:44:52, Jim Mellander (jmellander@lbl.gov) a écrit:

Hi:

For some reason I am having a lot of trouble wrapping my brain around
the Elasticsearch query capability.

I am trying to match for multiple values in specified fields

Here is what I am trying, but it returns no records:

{
"query": {
"filtered": {
"query" : { "match_all" : {} },
"filter" : {
"or" : [
{ "term" : { "field1":
"value1" }},
{ "term" : { "field2":
"value1" }},
{ "term" : { "field1":
"value2" }},
{ "term" : { "field2":
"value2" }}
]
}
}
}
}

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

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

Thanks David:

I am using the official python api, but I performed the curl search,
per the help page:

$ cat x
#!/bin/sh

curl -XGET 'http://localhost:9200/*/conn/_search' -d '{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"or": [
{"term": {"field1": "value1"}},
{"term": {"field2": "value1"}},
{"term": {"field1": "value2"}},
{"term": {"field2": "value2"}}
]
}
}
}
}'

$./x
{"took":15,"timed_out":false,"_shards":{"total":240,"successful":240,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}

Then, without the filter:

$ cat y
#!/bin/sh

curl -XGET 'http://localhost:9200/*/conn/_search' -d '{
"query": {
"filtered": {
"query": {"match_all": {}}
}
}
}'

$ ./y

{"took":10,"timed_out":false,"_shards":{"total":240,"successful":240,"failed":0},"hits":{"total":52470,"max_score":1.0,"hits":[
]}}

(and I verified that field1 and field2 are populated with and there
are records with value1 and value2 in those fields)

Thanks for taking the time to look at this - I assume there is
something wrong with the syntax of the query that is non-obvious (at
least to me).

P.S. - I searched in vain for a 'Elasticsearch for Dummies' resource -
the missing ingredient for me being a clear step-by-step methodology
and explanation of building queries for various operations - I'm
fairly certain that there are some fundamentals that I am missing, in
particular the hierarchy of the various options and how they interact.

On Tue, Nov 26, 2013 at 12:34 AM, David Pilato david@pilato.fr wrote:

Hi Jim,

Any chance that you could gist a full curl recreation to understand your
concern?
See Elasticsearch Platform — Find real-time answers at scale | Elastic

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 26 novembre 2013 at 00:44:52, Jim Mellander (jmellander@lbl.gov) a écrit:

Hi:

For some reason I am having a lot of trouble wrapping my brain around
the Elasticsearch query capability.

I am trying to match for multiple values in specified fields

Here is what I am trying, but it returns no records:

{
"query": {
"filtered": {
"query" : { "match_all" : {} },
"filter" : {
"or" : [
{ "term" : { "field1":
"value1" }},
{ "term" : { "field2":
"value1" }},
{ "term" : { "field1":
"value2" }},
{ "term" : { "field2":
"value2" }}
]
}
}
}
}

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

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

--
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/CADju%3Db4y5AnbY_DkVXbFp0Fv%2Bxq7BVCi%2BbUZny1qcE32yAttdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

There is no way to understand what is happening. I have no idea of what your docs look like. Mapping if any is unknown. That's the reason I gave you a link which explain in details what a curl recreation is.

Could you please follow the instructions?

It will help to run your script and try to understand what is happening without spending time on creating a test case.

Thanks.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 26 nov. 2013 à 18:45, Jim Mellander jmellander@lbl.gov a écrit :

Thanks David:

I am using the official python api, but I performed the curl search,
per the help page:

$ cat x
#!/bin/sh

curl -XGET 'http://localhost:9200/*/conn/_search' -d '{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"or": [
{"term": {"field1": "value1"}},
{"term": {"field2": "value1"}},
{"term": {"field1": "value2"}},
{"term": {"field2": "value2"}}
]
}
}
}
}'

$./x
{"took":15,"timed_out":false,"_shards":{"total":240,"successful":240,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}

Then, without the filter:

$ cat y
#!/bin/sh

curl -XGET 'http://localhost:9200/*/conn/_search' -d '{
"query": {
"filtered": {
"query": {"match_all": {}}
}
}
}'

$ ./y

{"took":10,"timed_out":false,"_shards":{"total":240,"successful":240,"failed":0},"hits":{"total":52470,"max_score":1.0,"hits":[
]}}

(and I verified that field1 and field2 are populated with and there
are records with value1 and value2 in those fields)

Thanks for taking the time to look at this - I assume there is
something wrong with the syntax of the query that is non-obvious (at
least to me).

P.S. - I searched in vain for a 'Elasticsearch for Dummies' resource -
the missing ingredient for me being a clear step-by-step methodology
and explanation of building queries for various operations - I'm
fairly certain that there are some fundamentals that I am missing, in
particular the hierarchy of the various options and how they interact.

On Tue, Nov 26, 2013 at 12:34 AM, David Pilato david@pilato.fr wrote:
Hi Jim,

Any chance that you could gist a full curl recreation to understand your
concern?
See Elasticsearch Platform — Find real-time answers at scale | Elastic

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 26 novembre 2013 at 00:44:52, Jim Mellander (jmellander@lbl.gov) a écrit:

Hi:

For some reason I am having a lot of trouble wrapping my brain around
the Elasticsearch query capability.

I am trying to match for multiple values in specified fields

Here is what I am trying, but it returns no records:

{
"query": {
"filtered": {
"query" : { "match_all" : {} },
"filter" : {
"or" : [
{ "term" : { "field1":
"value1" }},
{ "term" : { "field2":
"value1" }},
{ "term" : { "field1":
"value2" }},
{ "term" : { "field2":
"value2" }}
]
}
}
}
}

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

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

--
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/CADju%3Db4y5AnbY_DkVXbFp0Fv%2Bxq7BVCi%2BbUZny1qcE32yAttdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/5BB9A2A3-2364-461B-8E5C-C22EA85894E8%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.