Reputation: 741
I am creating an index with elastic search and want to be able to sort on the "field" country_en (I might want to add another field later). However the sorting result is not correctly.
A descending order would return
When I sort ascending the order is different again, but not on alphabet.
The command I give to create the index is:
curl -XPUT "localhost:9200/_river/tenders/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers": [
{ "host": "127.0.0.1", "port": 27017 }
],
"options": { "secondary_read_preference": true },
"db": "jna",
"collection": "tenders"
},
"index": {
"name": "tenders",
"type": "string",
"bulk": {
"concurrent_requests": 2
}
},
"mappings" : {
"country" : {
"_source" : { "enabled" : true },
"properties" : {
"country_en" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
The search is done via the elastic search PHP library. The command is an array but I converted it to JSON using PHP json_encode.
{
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "_all",
"query": "Liability*"
}
}
]
}
},
"from": 0,
"size": "25",
"sort": {
"country_en": {
"order": "asc",
"ignore_unmapped": true
}
}
}
}
Data that is being indexed
{
"_id": ObjectId("53bd88db557acd276d8b4d5f"),
"userid": null,
"importdate": ISODate("2014-07-09T18:24:27.0Z"),
"documentnumber": "230476-2014",
"source": "ted",
"typeoftender": "public",
"categories": {
"0": ObjectId("5210c86d9b7e7a3803000010")
},
"data": {
"oj": "129",
"ol": "de",
"cy": "de",
"ds": "0.00000000 1404424800",
"dt": ISODate("2014-08-10T22:00:00.0Z"),
"aa": NumberLong(1),
"td": NumberLong(3),
"nc": NumberLong(2),
"pr": NumberLong(2),
"ty": NumberLong(1),
"ac": NumberLong(1),
"heading": "01202",
"cpv": {
"0": "33600000"
}
},
"type": "public",
"title_en": "Pharmaceutical products",
"category_en": "Pharmaceuticals",
"country_en": "Germany",
}
Upvotes: 4
Views: 4896
Reputation: 27487
If you are having issues that require ignore_unmapped to be set to true, it would imply that you are having mapping problems. There have been others who have had similar issues with mappings with the MongoDB river. I'd suggest the following course of action:
I would set dynamic mapping to false or set it to strict for the type you are using with river:
The dynamic creation of mappings for unmapped types can be completely disabled by setting index.mapper.dynamic to false.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-dynamic-mapping.html
I would also take a look at this discussion concerning custom mappings and the MongoDB river and in particular how people were able to address it by setting dynamic mapping to false:
https://github.com/richardwilly98/elasticsearch-river-mongodb/issues/75
Upvotes: 1