Lucene syntax for match all docs

I believe the Lucene query parser translates the query ":" into a
MatchAllDocsQuery, whereas our ES cluster is returning 0 documents for the
query:

{ "query": { "query_string": "." } }

I know we can do:

{ "query": { "match_all": { } } }

But I would still like to understand what's happening.

Can someone explain why the ES query parser is acting this way? Am I
incorrect in my understanding of the behavior of the Lucene query parser?

Thanks,

  • Ash

--
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.

Try:
{ "query": { "query_string": "*" } }

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

Le 5 févr. 2013 à 22:53, hanafy.ash@gmail.com a écrit :

I believe the Lucene query parser translates the query ":" into a MatchAllDocsQuery, whereas our ES cluster is returning 0 documents for the query:

{ "query": { "query_string": "." } }

I know we can do:

{ "query": { "match_all": { } } }

But I would still like to understand what's happening.

Can someone explain why the ES query parser is acting this way? Am I incorrect in my understanding of the behavior of the Lucene query parser?

Thanks,

--
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.

On Tue, 2013-02-05 at 13:53 -0800, hanafy.ash@gmail.com wrote:

I believe the Lucene query parser translates the query ":" into a
MatchAllDocsQuery, whereas our ES cluster is returning 0 documents for
the query:

{ "query": { "query_string": "." } }

You correctly specify the match-all query as ':' but then you test it
as '.'

clint

--
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 for pointing out my typo Clinton. However, we were indeed using the
":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d
'{"query":{"query_string":{"query":":"}}}'
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

However, the "" query suggested by David does work as expected. But I
still don't understand why that is the case? We currently have the _all
field enabled, and it is the default field for searching, but every field
we index has in our mappings include_in_all: false (this is only temporary
of course). So what does the query_string '
' mean? And why doesn't ":"
work as expected?

On Wednesday, February 6, 2013 5:34:03 AM UTC-5, Clinton Gormley wrote:

On Tue, 2013-02-05 at 13:53 -0800, hanaf...@gmail.com <javascript:>wrote:

I believe the Lucene query parser translates the query ":" into a
MatchAllDocsQuery, whereas our ES cluster is returning 0 documents for
the query:

{ "query": { "query_string": "." } }

You correctly specify the match-all query as ':' but then you test it
as '.'

clint

--
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.

I think you can use a matchQuery with ":".
I did not try myself but it should work, no?

By default a QueryString search only on _all special field. This field contain all your structured fields content.
So * means search anything on _all field.

Searching for fieldname:* does not search in _all field but in "fieldname".

Does it help?

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

Le 6 févr. 2013 à 15:19, hanafy.ash@gmail.com a écrit :

Thanks for pointing out my typo Clinton. However, we were indeed using the ":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d '{"query":{"query_string":{"query":":"}}}'
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

However, the "" query suggested by David does work as expected. But I still don't understand why that is the case? We currently have the _all field enabled, and it is the default field for searching, but every field we index has in our mappings include_in_all: false (this is only temporary of course). So what does the query_string '' mean? And why doesn't ":" work as expected?

On Wednesday, February 6, 2013 5:34:03 AM UTC-5, Clinton Gormley wrote:
On Tue, 2013-02-05 at 13:53 -0800, hanaf...@gmail.com wrote:

I believe the Lucene query parser translates the query ":" into a
MatchAllDocsQuery, whereas our ES cluster is returning 0 documents for
the query:

{ "query": { "query_string": "." } }

You correctly specify the match-all query as ':' but then you test it
as '.'

clint

--
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.

On Wed, 2013-02-06 at 06:19 -0800, hanafy.ash@gmail.com wrote:

Thanks for pointing out my typo Clinton. However, we were indeed
using the ":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d
'{"query":{"query_string":{"query":":"}}}'

what version of ES is this?

When I look at the code in master, it has this in the query string
wildcard parsing:

if (actualField == null) {
    return newMatchAllDocsQuery();
}
if ("*".equals(actualField) || "_all".equals(actualField)) {
    return newMatchAllDocsQuery();
}

which means that * _all:* and : should all work

Certainly that's the case when I test it out

clint

--
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.

We are using elasticsearch 0.20.1, were those code changes recent?

'_all:' and '' work, but not ':'

Clinton, could you point me at where in the source you found the code that
parses the query? Thanks again for the help.

  • Ash

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d
'{"query":{"query_string":{"query":"*"}}}'

{
"took" : 10,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d
'{"query":{"query_string":{"query":"_all:*"}}}'
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d
'{"query":{"query_string":{"query":":"}}}'

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

On Wednesday, February 6, 2013 9:38:52 AM UTC-5, Clinton Gormley wrote:

On Wed, 2013-02-06 at 06:19 -0800, hanaf...@gmail.com <javascript:>wrote:

Thanks for pointing out my typo Clinton. However, we were indeed
using the ":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d
'{"query":{"query_string":{"query":":"}}}'

what version of ES is this?

When I look at the code in master, it has this in the query string
wildcard parsing:

if (actualField == null) { 
    return newMatchAllDocsQuery(); 
} 
if ("*".equals(actualField) || "_all".equals(actualField)) { 
    return newMatchAllDocsQuery(); 
} 

which means that * _all:* and : should all work

Certainly that's the case when I test it out

clint

--
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.

It was fixed in 0.20.2. See *:* query not working · Issue #2486 · elastic/elasticsearch · GitHub

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

Le 6 févr. 2013 à 15:54, hanafy.ash@gmail.com a écrit :

We are using elasticsearch 0.20.1, were those code changes recent?

'_all:' and '' work, but not ':'

Clinton, could you point me at where in the source you found the code that parses the query? Thanks again for the help.

  • Ash

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d '{"query":{"query_string":{"query":"*"}}}'
{
"took" : 10,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d '{"query":{"query_string":{"query":"_all:*"}}}'
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all' -d '{"query":{"query_string":{"query":":"}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

On Wednesday, February 6, 2013 9:38:52 AM UTC-5, Clinton Gormley wrote:
On Wed, 2013-02-06 at 06:19 -0800, hanaf...@gmail.com wrote:

Thanks for pointing out my typo Clinton. However, we were indeed
using the ":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d
'{"query":{"query_string":{"query":":"}}}'

what version of ES is this?

When I look at the code in master, it has this in the query string
wildcard parsing:

if (actualField == null) { 
    return newMatchAllDocsQuery(); 
} 
if ("*".equals(actualField) || "_all".equals(actualField)) { 
    return newMatchAllDocsQuery(); 
} 

which means that * _all:* and : should all work

Certainly that's the case when I test it out

clint

--
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 for the quick responses! We will update elasticsearch to >= 0.20.2
and try this out

  • Ash

On Wednesday, February 6, 2013 10:04:11 AM UTC-5, David Pilato wrote:

It was fixed in 0.20.2. See
*:* query not working · Issue #2486 · elastic/elasticsearch · GitHub

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 6 févr. 2013 à 15:54, hanaf...@gmail.com <javascript:> a écrit :

We are using elasticsearch 0.20.1, were those code changes recent?

'_all:' and '' work, but not ':'

Clinton, could you point me at where in the source you found the code that
parses the query? Thanks again for the help.

  • Ash

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all'-d '{"query":{"query_string":{"query":"*"}}}'

{
"took" : 10,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all'-d '{"query":{"query_string":{"query":"_all:*"}}}'
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "documents",
"_type" : "document",
"_id" : "blah",
"_score" : 1.0
}, {
"_index" : "documents",
"_type" : "document",
"_id" : "boom",
"_score" : 1.0
} ]
}
}

curl -X GET 'http://localhost:9200/documents/_search?pretty&fields=all'-d '{"query":{"query_string":{"query":":"}}}'

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

On Wednesday, February 6, 2013 9:38:52 AM UTC-5, Clinton Gormley wrote:

On Wed, 2013-02-06 at 06:19 -0800, hanaf...@gmail.com wrote:

Thanks for pointing out my typo Clinton. However, we were indeed
using the ":" for the query:

curl -X GET 'http://localhost:9200/documents/_search?pretty' -d
'{"query":{"query_string":{"query":":"}}}'

what version of ES is this?

When I look at the code in master, it has this in the query string
wildcard parsing:

if (actualField == null) { 
    return newMatchAllDocsQuery(); 
} 
if ("*".equals(actualField) || "_all".equals(actualField)) { 
    return newMatchAllDocsQuery(); 
} 

which means that * _all:* and : should all work

Certainly that's the case when I test it out

clint

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.