ich benutze chewy gem elasticsearch.rails: typ suche mit daten adresse verwenden elasticsearch zäh gem
Ich habe LocationsIndex, mapping:
class LocationsIndex < Chewy::Index
settings analysis: {
analyzer: {
folding: {
tokenizer: "standard",
filter: [ "lowercase", "asciifolding" ]
},
sorted: {
tokenizer: 'keyword',
filter: ['lowercase', 'asciifolding']
}
}
}
define_type Location do
field :name, type: 'string', analyzer: 'standard' do
field :folded, type: 'string', analyzer: "folding"
end
field :address, type: 'string', analyzer: 'standard' do
field :address, type: 'string', analyzer: 'folding'
end
field :locations, type: 'geo_point', value: ->{ {lat: lat, lon: lon} }
end
end
, wenn ich fragen:
LocationsIndex::Location.query(
multi_match: {
query: keyword,
fields: ["address", "address.folded" ,"name", "name.folded"]
}
)
Daten Beispiel:
{ "nahm": 2 "timed_out": false, "_shards": { "gesamt": 5, "erfolgreich": 5, "fehlgeschlagen": 0}, "Treffer": { "total": 10, "max_score": 1,0, "Treffer": [{ "_index": "Orte", "_type": "location", "_id": "131", " _score ": 1.0, " _source ": {" Name ":" Việt Nam "," Adresse ":" Việt Nam "," Orte ": {" lat ": 16.9054," lon ": 106.576}} }, { "_index": "Orte", "_type": "location", "_id": "136", "_score": 1,0, "_Source": { "name": "Quan Truong Ngo Mon "," Adresse ":" 23/8, Thừa Thiên Huế, Việt Nam "," Standorte ": {" lat ": 16.4669," lon ": 107.58}} }, { " _index ":" Standorte ", "_type": "Standort", "_id": "132", "_score": 1.0, "_source": {"Name": "Thừa Thiên Huế", "Adresse": "Thừa Thiên Huế, Việt Nam "," Standorte ": {" lat ": 16.4674," lon ": 107.591}} }, { " _index ":" Standorte ", " _type ":" Standort ", " _id ":" 137 ", " _score ": 1.0, " _source ": {" Name ":" Phu Van Lau "," Adresse ":" 23/8, Thừa Thiên Huế, Việt Nam "," Standorte ": {" lat ": 16,4655," lon ": 107,581}} }, { "_index": "Orte", "_type": "location", "_id": "133", "_score": 1,0, "_source": {"Name": "Ha Noi", "Adresse": "Ha Noi, Việt Nam", "Orte": {"lat": 16.4674, "lon": 107.591}} }, { } "_index": "Orte", "_type": "Ort", "_id": "138", "_score": 1,0, "_source": {"name": "Cau gia Vien", " Adresse ":" Le Duan, Thừa Thiên Huế, Việt Nam "," Standorte ": {" lat ": 16.4601," lon ": 107.571}} }, { " _index ":" Standorte ", " _type " : "Ort", "_id": "134", "_score": 1.0, "_source": {"Name": "TP Ho Chi Minh", "Adresse": "TP Ho Chi Minh, Việt Nam "," Standorte ": {" lat ": 16.4674," lon ": 107.591}} }, { " _ index ":" locations ", " _type ":" location ", " _id ":" 139 ", " _score ": 1.0, " _source ": {" name ":" Chua Thien Pagode "," adresse ":" Kim Long, Thừa Thiên Huế, Việt Nam "," Standorte ": {" lat ": 16.4537," lon ": 107.545}} }, { " _index ":" Standorte ", " _type ": "Standort", "_id": "130", "_score": 1.0, "_source": {"Name": "Việt Nam", "Adresse": "Việt Nam", "Standorte": {" lat ": 16.9054," lon ": 106.576 }}}, { "_index": "Orte", "_type" "location", "_id": "135", "_score": 1,0, "_Source": { "name" "Zitadelle Hue", "Adresse": "23/8, Thua Thien-Hue, Vietnam", "Orte": { "lat": 16,4698, "Dosen": 107 577 }}}]}}
schütteln, wenn ich mit keyword = "nam" Abfrage
result :
_id = [131,132,,133,134,135,136,137,138,139,130] # => OK working
aber ich KHI mit keywork Abfrage Zittern = "Thua Thien Hue"
result :
_id = [132,135,139] # => Don't working ???, should have been: _id = [132,135,136,137,138,139]
Same mit keywork = "Farbton"
result :
_id = [132,135] # => Don't working ???, should have been: _id = [132,135,136,137,138,139]
có, wie Suchergebnisse Chua oben Wort (Typ hinzufügen, oder durch irgendetwas)