Skip to content

Instantly share code, notes, and snippets.

@feymartynov
Last active August 29, 2015 14:04
Show Gist options
  • Save feymartynov/c0c2c643c97812c7316a to your computer and use it in GitHub Desktop.
Save feymartynov/c0c2c643c97812c7316a to your computer and use it in GitHub Desktop.
elasticsearch trouble

Search country using russian query by all fields with prefix "name". Everything's ok.

➜ curl -XGET 'http://localhost:9200/geo/country/_search?pretty' -d '{ query: { multi_match: { fields: ["name*"], query: "Австрия" } } }'
{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 8.52575,
    "hits" : [ {
      "_index" : "geo",
      "_type" : "country",
      "_id" : "4",
      "_score" : 8.52575,
      "_source":{"id":4,"world_region_id":1,"slug":"austria","code":"AT","name_en":"Austria","name_de":"Österreich","name_ru":"Австрия","name_it":"Austria","name_es":"Austria","name_fr":"Autriche","name_zh":"奥地利"}
    } ]
  }
}

But when it comes to multi-type search with there are no results:

➜ curl -XGET 'http://localhost:9200/geo/city,country/_search?pretty' -d '{ query: { multi_match: { fields: ["name*"], query: "Австрия" } } }'
{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

However, multi-type search in English goes well:

➜ curl -XGET 'http://localhost:9200/geo/city,country/_search?pretty' -d '{ query: { multi_match: { fields: ["name*"], query: "Austria" } } }'
{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 8.52575,
    "hits" : [ {
      "_index" : "geo",
      "_type" : "country",
      "_id" : "4",
      "_score" : 8.52575,
      "_source":{"id":4,"world_region_id":1,"slug":"austria","code":"AT","name_en":"Austria","name_de":"Österreich","name_ru":"Австрия","name_it":"Austria","name_es":"Austria","name_fr":"Autriche","name_zh":"奥地利"}
    } ]
  }
}
{
"geo" : {
"mappings" : {
"country" : {
"properties" : {
"code" : {
"type" : "string",
"index" : "no"
},
"id" : {
"type" : "integer"
},
"name_de" : {
"type" : "string",
"analyzer" : "german"
},
"name_en" : {
"type" : "string",
"analyzer" : "english"
},
"name_es" : {
"type" : "string",
"analyzer" : "spanish"
},
"name_fr" : {
"type" : "string",
"analyzer" : "french"
},
"name_it" : {
"type" : "string",
"analyzer" : "italian"
},
"name_ru" : {
"type" : "string",
"analyzer" : "russian"
},
"name_zh" : {
"type" : "string",
"analyzer" : "chinese"
},
"slug" : {
"type" : "string",
"index" : "no"
}
}
},
"city" : {
"properties" : {
"country_id" : {
"type" : "long"
},
"iata" : {
"type" : "string"
},
"id" : {
"type" : "long"
},
"name_de" : {
"type" : "string"
},
"name_en" : {
"type" : "string"
},
"name_es" : {
"type" : "string"
},
"name_fr" : {
"type" : "string"
},
"name_it" : {
"type" : "string"
},
"name_ru" : {
"type" : "string"
},
"name_zh" : {
"type" : "string"
},
"region_id" : {
"type" : "long"
},
"slug" : {
"type" : "string"
},
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment