Query_string not working after updating from 1.7 to 2.4


(Romain Giovanetti) #1

Hello,

Since I updated my cluster from 1.7 to 2.4 the query_string query stopped working.

However the term query still works.

Let's say I put 3 documents in the "us" index :

curl -XPUT 'http://localhost:9200/us/tweet/10?pretty=1' -d '
{
   "date" : "2014-09-20",
   "name" : "John Smith",
   "tweet" : "Elasticsearch surely is one of the hottest new NoSQL products",
   "user_id" : 1
}
'
curl -XPUT 'http://localhost:9200/us/tweet/12?pretty=1' -d '
{
   "date" : "2014-09-22",
   "name" : "John Smith",
   "tweet" : "Elasticsearch and I have left the honeymoon stage, and I still love her.",
   "user_id" : 1
}
'
curl -XPUT 'http://localhost:9200/us/tweet/4?pretty=1' -d '
{
   "date" : "2014-09-14",
   "name" : "John Smith",
   "tweet" : "@mary it is not just text, it does everything",
   "user_id" : 1
}
'

Then if I execute the following query :

{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "tweet.tweet",
"query": "elasticsearch"
}
}
],
"must_not": [ ],
"should": [ ]
}
},
"from": 0,
"size": 10,
"sort": [ ],
"aggs": { }
}

I get

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

I can't figure out why.

I checked the logs and I see nothing wrong.

Can you help me?

Thanks


(JavaES) #2

HI Romain,giovanetti

GET us/tweet/_search
{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "tweet",
"query": "elasticsearch"
}
}
]
}

}
}

Could you please check with this one.


(Romain Giovanetti) #3

:weary:

I tried your solution and it worked....

Then I tried my solution again and it worked too.

I don't understand :confused:

Sometimes it works and sometimes not...

I use the indices.fielddata.cache.size setting (30%), could it be the problem ?


(Romain Giovanetti) #4

I'm starting to figure out that it works when I use a GET but the results are false

The Head plugin gives me the following URL

http://localhost:9200/us/tweet/_search?{"query":{"bool":{"filter":[{"query_string":{"default_field":"tweet.tweet","query":"elasticsearch"}}],%22must_not%22:[],%22should%22:[]}},%22from%22:0,%22size%22:10,%22sort%22:[],%22aggs%22:{}}

and it returns all the documents including :

{
"_index": "us",
"_type": "tweet",
"_id": "4",
"_score": 1,
"_source": {
"date": "2014-09-14",
"name": "John Smith",
"tweet": "@mary it is not just text, it does everything",
"user_id": 1
}
}

which doesn't contain the word "elasticsearch"

EDIT: your solution using POST works

EDIT2: it seems that all my issues were related to the name used for the fields (tweet.tweet vs tweet).

Thank you for your help

And sorry for this stupid question, I feel tired


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.