Skip to content

Instantly share code, notes, and snippets.

@joren
Created July 31, 2013 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joren/6120279 to your computer and use it in GitHub Desktop.
Save joren/6120279 to your computer and use it in GitHub Desktop.
Elasticsearch problem. Same anaylizer, but two different ways to search. 1. {"query":{"query_string":{"query":"name:jore"}} 2. {"query":{"query_string":{"query":"jore"}} So once with a specific field and once without. Giving differen results when I search with or without a space in the query.
settings analysis: {
filter: {
myNgram: {
type: 'nGram',
max_gram: 12,
min_gram: 3
}
},
analyzer: {
name_analyzer: {
tokenizer: 'standard',
filter: %w[lowercase myNgram],
type: 'custom'
},
}
}
~ curl -X GET 'http://localhost:9200/clients/client/_search?load=true&size=4&pretty' -d '{"query":{"query_string":{"query":"name:jm brun"}},"size":4}' ruby-2.0.0
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}%
~ curl -X GET 'http://localhost:9200/clients/client/_search?load=true&size=4&pretty' -d '{"query":{"query_string":{"query":"jm brun"}},"size":4}' ruby-2.0.0
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.6683317,
"hits" : [ {
"_index" : "clients",
"_type" : "client",
"_id" : "65",
"_score" : 0.6683317, "_source" : {"name":"JM Bruneau","shortname":"jm_bruneau"}
} ]
}
}%
~ curl -X GET 'http://localhost:9200/clients/client/_search?load=true&size=4&pretty' -d '{"query":{"query_string":{"query":"name:jore"}},"size":4}' ruby-2.0.0
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 12,
"max_score" : 2.2767696,
"hits" : [ {
"_index" : "clients",
"_type" : "client",
"_id" : "273",
"_score" : 2.2767696, "_source" : {"name":"Joren De Groof","shortname":"joren"}
}, {
"_index" : "clients",
"_type" : "client",
"_id" : "1070",
"_score" : 1.1383848, "_source" : {"name":"jorendegroof","shortname":"jorendegroof"}
} ]
}
}%
~ curl -X GET 'http://localhost:9200/clients/client/_search?load=true&size=4&pretty' -d '{"query":{"query_string":{"query":"jore"}},"size":4}' ruby-2.0.0
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment