Json query not returning results


(Levon Tamrazov) #1

Hi,
I am learning elasticsearch and following along with the tutorial. I
uploaded three documents into an index. When I supply the following query:

curl 'localhost:9200/vehicles/_search?query=driver.name:Jon'

I as expected get back object two and object three. However when I try
querying using json:

curl localhost:9200/vehicles/_search -d'

{

"query":{

"prefix":{

"driver.name":"Jon"

}}}'

I get no results back. I am following the tutorial very closely, so I don't
understand what the issue is. Any help would be really appreciated. The
uploaded objects are below.

Thank you!
id:one
'{
"color": "green",
"driver": {
"born":"1989-09-12",
"name": "Ben"
},
"make": "BMW",
"model": "Aztek",
"value": 3000.0,
"year": 2003
}'

id:two
'{
"color": "black",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "Mercedes",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

id:three
'{
"color": "green",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "BMW",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

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


(David Pilato) #2

Try with jon lowercase.

Prefix query is not analyzed.
But your field has been indexed as "jon".

HTH

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

Le 23 nov. 2013 à 17:43, Levon Tamrazov ltamrazov@gmail.com a écrit :

Hi,
I am learning elasticsearch and following along with the tutorial. I uploaded three documents into an index. When I supply the following query:

curl 'localhost:9200/vehicles/_search?query=driver.name:Jon'

I as expected get back object two and object three. However when I try querying using json:

curl localhost:9200/vehicles/_search -d'

{

"query":{

"prefix":{

"driver.name":"Jon"

}}}'

I get no results back. I am following the tutorial very closely, so I don't understand what the issue is. Any help would be really appreciated. The uploaded objects are below.

Thank you!

id:one
'{
"color": "green",
"driver": {
"born":"1989-09-12",
"name": "Ben"
},
"make": "BMW",
"model": "Aztek",
"value": 3000.0,
"year": 2003
}'

id:two
'{
"color": "black",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "Mercedes",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

id:three
'{
"color": "green",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "BMW",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

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.


(Levon Tamrazov) #3

Thank you! That was exactly it, worked like a charm.

On Saturday, 23 November 2013 13:21:13 UTC-5, David Pilato wrote:

Try with jon lowercase.

Prefix query is not analyzed.
But your field has been indexed as "jon".

HTH

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

Le 23 nov. 2013 à 17:43, Levon Tamrazov <ltam...@gmail.com <javascript:>>
a écrit :

Hi,
I am learning elasticsearch and following along with the tutorial. I
uploaded three documents into an index. When I supply the following query:

curl 'localhost:9200/vehicles/_search?query=driver.name:Jon'

I as expected get back object two and object three. However when I try
querying using json:

curl localhost:9200/vehicles/_search -d'

{

"query":{

"prefix":{

"driver.namehttp://www.google.com/url?q=http%3A%2F%2Fdriver.name&sa=D&sntz=1&usg=AFQjCNErou1shw6oSTaKg-2VfDONgFOsSA
":"Jon"

}}}'

I get no results back. I am following the tutorial very closely, so I
don't understand what the issue is. Any help would be really appreciated.
The uploaded objects are below.

Thank you!
id:one
'{
"color": "green",
"driver": {
"born":"1989-09-12",
"name": "Ben"
},
"make": "BMW",
"model": "Aztek",
"value": 3000.0,
"year": 2003
}'

id:two
'{
"color": "black",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "Mercedes",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

id:three
'{
"color": "green",
"driver": {
"born":"1934-09-08",
"name": "Jon"
},
"make": "BMW",
"model": "Benz",
"value": 10000.0,
"year": 2012
}'

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


(system) #4