Elasticsearch v0.90.1 Querystring not working for value : "IN" and "IT"


(Mahesh kumar) #1

In v0.90.1 , I have indexed following data :

"hits" : [ {
"_index" : "movies",
"_type" : "movie",
"_id" : "4",
"_score" : 1.0, "_source" : {"title": "44The Godfather","director": "44Francis","year": 441972,"country_code": "IT"}
}, {
"_index" : "movies",
"_type" : "movie",
"_id" : "5",
"_score" : 1.0, "_source" : {"title": "55The Godfather","director": "55Francis","year": 551972,"country_code": "INS"}
}, {
"_index" : "movies",
"_type" : "movie",
"_id" : "1",
"_score" : 1.0, "_source" : {"title": "22The Godfather","director": "22Francis","year": 221972,"country_code": "US"}
}, {
"_index" : "movies",
"_type" : "movie",
"_id" : "6",
"_score" : 1.0, "_source" : {"title": "66The Godfather","director": "66Francis","year": 661972,"country_code": "MN"}
}, {
"_index" : "movies",
"_type" : "movie",
"_id" : "2",
"_score" : 1.0, "_source" : {"title": "The Godfather","director": "Francis","year": 1972,"country_code": "IN"}
}, {
"_index" : "movies",
"_type" : "movie",
"_id" : "3",
"_score" : 1.0, "_source" : {"title": "33The Godfather","director": "33Francis","year": 331972,"country_code": "I"}
} ]

But when i was trying to fetch it using querystring it returns me data for "US", "I", "INS", "MN" but not returning any data for "IT" and "IN"

Query :=>

'{"query":{"bool":{"should":[{"query_string":{"default_field":"country_code","query":"US"}}],"minimum_number_should_match":1}}}'

result :=>

{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "movies",
"_type" : "movie",
"_id" : "1",
"_score" : 1.0, "_source" : {"title": "22The Godfather","director": "22Francis","year": 221972,"country_code": "US"}
} ]
}
}

For "IN" : Query =>

'{"query":{"bool":{"should":[{"query_string":{"default_field":"country_code","query":"IN"}}],"minimum_number_should_match":1}}}'

Result :=>

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

I just dont know why it is not working for "IT" and "IN" ,But the same query works in latest version for both "IN" and "IT".
Is anyone facing the same problem for version 0.90.1? Is there any way to make it work in same version without upgrading?


(Mark Harwood) #2

The problem is likely the "Analyzer" that is used to process your strings ready for search.
A typical technique[1] is to remove common "stop words" such [as, an, of, the...] that don't convey much information in English.
However, your country data is not free-text - it is a structured field with a fixed vocab so it doesn't make sense to use an Analyzer that removes common English words like it and in. You'll need to change your mapping definition appropriately.

[1] https://www.elastic.co/blog/found-indexing-for-beginners-part2 (old article but relevant intro)


(Mahesh kumar) #3

Thanks @Mark_Harwood that was really helpful, I didn't knw about stop words in elasticsearch. :slight_smile:


(David Pilato) #4

But please. Upgrade!


(system) #5

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