Problem with searching via json api

Hi there,

I have a problem with elastic search when using the json query api
(using terms)

The following query works:

curl -XPOST

'localhost:9200/example-app/car/_search?q=brand:Audi&pretty=true'

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4054651,
"hits" : [ {
"_index" : "example-app",
"_type" : "car",
"_id" : "220",
"_score" : 1.4054651, "_source" :
{"brand":"Audi","type":"A5","price":60000}
} ]
}
}

This query does not work:

curl -XPOST 'localhost:9200/example-app/car/_search?pretty=true' -d

'
{ "query": { "term" : { "brand" : "Audi" }}}'

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

I am supposing that I simply misunderstood the basic query
capabilities. There are no exceptions in the logs either, so I think
it must be some beginners mistake.

Any help is greatly appreciated!

--Alexander

Queries made using the _search?q= syntax will be analyzed by the
default analyzer before searching. Term queries using the DSL are NOT
analyzed. I assume that the "brand" field is analyzed and therefore
the query DSL is not working. Try searching for lower "audi".

Ivan

On Mar 7, 7:27 pm, Alexander Reelsen
alexander.reel...@googlemail.com wrote:

Hi there,

I have a problem with Elasticsearch when using the json query api
(using terms)

The following query works:

curl -XPOST

'localhost:9200/example-app/car/_search?q=brand:Audi&pretty=true'

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4054651,
"hits" : [ {
"_index" : "example-app",
"_type" : "car",
"_id" : "220",
"_score" : 1.4054651, "_source" :
{"brand":"Audi","type":"A5","price":60000}
} ]
}

}

This query does not work:

curl -XPOST 'localhost:9200/example-app/car/_search?pretty=true' -d

'
{ "query": { "term" : { "brand" : "Audi" }}}'

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

}

I am supposing that I simply misunderstood the basic query
capabilities. There are no exceptions in the logs either, so I think
it must be some beginners mistake.

Any help is greatly appreciated!

--Alexander

Another option is to use the query_string or field query in the query DSL, instead of the term query.
On Tuesday, March 8, 2011 at 4:54 AM, Ivan Brusic wrote:

Queries made using the _search?q= syntax will be analyzed by the
default analyzer before searching. Term queries using the DSL are NOT
analyzed. I assume that the "brand" field is analyzed and therefore
the query DSL is not working. Try searching for lower "audi".

Ivan

On Mar 7, 7:27 pm, Alexander Reelsen
alexander.reel...@googlemail.com wrote:

Hi there,

I have a problem with Elasticsearch when using the json query api
(using terms)

The following query works:

curl -XPOST

'localhost:9200/example-app/car/_search?q=brand:Audi&pretty=true'

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4054651,
"hits" : [ {
"_index" : "example-app",
"_type" : "car",
"_id" : "220",
"_score" : 1.4054651, "_source" :
{"brand":"Audi","type":"A5","price":60000}
} ]
}

}

This query does not work:

curl -XPOST 'localhost:9200/example-app/car/_search?pretty=true' -d

'
{ "query": { "term" : { "brand" : "Audi" }}}'

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

}

I am supposing that I simply misunderstood the basic query
capabilities. There are no exceptions in the logs either, so I think
it must be some beginners mistake.

Any help is greatly appreciated!

--Alexander