Errors for search


(曹江华) #1

[root@localhost ~]# curl -XGET 'http://localhost:9200/twitter/tweet/
_search' -d '

{

    query : {
        term : { "user" : "tujiao" }
    },
    filter : {
        term : { "sortid" : "2"}
    }

}'
{"error":"SearchPhaseExecutionException[Failed to execute [query]
total failure; shardFailures {[5a012b9d-b0ef-411a-8429-ce5f0d0e9ec7]
[twitter][0]: SearchParseException[[twitter][0]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [Failed to parse
[\n{\n\n query : {\n term : { "user" : "tujiao" }
\n },\n filter : {\n term : { "sortid" :
"2"}\n }\n\n}]]]; nested: SearchParseException[[twitter][0]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [No parser for
element [filter]]]; }{[5a012b9d-b0ef-411a-8429-ce5f0d0e9ec7][twitter]
[2]: SearchParseException[[twitter][2]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [Failed to parse
[\n{\n\n query : {\n term : { "user" : "tujiao" }
\n },\n filter : {\n term : { "sortid" :
"2"}\n }\n\n}]]]; nested: SearchParseException[[twitter][2]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [No parser for
element [filter]]]; }{[5a012b9d-b0ef-411a-8429-ce5f0d0e9ec7][twitter]
[4]: SearchParseException[[twitter][4]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [Failed to parse
[\n{\n\n query : {\n term : { "user" : "tujiao" }
\n },\n filter : {\n term : { "sortid" :
"2"}\n }\n\n}]]]; nested: SearchParseException[[twitter][4]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [No parser for
element [filter]]]; }{[5a012b9d-b0ef-411a-8429-ce5f0d0e9ec7][twitter]
[3]: SearchParseException[[twitter][3]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [Failed to parse
[\n{\n\n query : {\n term : { "user" : "tujiao" }
\n },\n filter : {\n term : { "sortid" :
"2"}\n }\n\n}]]]; nested: SearchParseException[[twitter][3]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [No parser for
element [filter]]]; }{[5a012b9d-b0ef-411a-8429-ce5f0d0e9ec7][twitter]
[1]: SearchParseException[[twitter][1]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [Failed to parse
[\n{\n\n query : {\n term : { "user" : "tujiao" }
\n },\n filter : {\n term : { "sortid" :
"2"}\n }\n\n}]]]; nested: SearchParseException[[twitter][1]:
query[user:tujiao],from[-1],size[-1]: Parse Failure [No parser for
element [filter]]]; }]"}

why? who can tell me reason?


(Clinton Gormley) #2

On Mon, 2010-05-17 at 11:03 -0700, 曹江华 wrote:

[root@localhost ~]# curl -XGET 'http://localhost:9200/twitter/tweet/
_search' -d '

{

    query : {
        term : { "user" : "tujiao" }
    },
    filter : {
        term : { "sortid" : "2"}
    }

}'

This is what you want:

curl -XGET 'http://localhost:9200/twitter/tweet/search' -d '
{
"query": {
"filtered" : {
"query" : {
"term" : { "tag" : "wow" }
},
"filter" : {
"range" : {
"age" : { "from" : 10, "to" : 20 }
}
}
}
}
}

See http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/filtered_query/

Clint

--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.


(system) #3