Elasticsearch Indexerstellung mit Mapping
Ich habe mit der einfachen Aufgabe der Indexerstellung zu kämpfen. Das Ziel besteht darin, einen Index mit einem Analysator und einer Feldzuordnung zu erstellen. Wenn ich einen Index mit einem Analyzer erstelle, kann ich über die Analyzer-API-Aufrufe mit dem Analyzer sprechen, aber wenn ich die Zuordnungsinformationen hinzufüge, schlagen die Aufrufe zum Erstellen eines Index mit "Analyzer [Analyzer1] nicht gefunden für Feld [$ Feld]]" fehl hat ein Skript erstellt, um das Problem zu zeigen:
#!/bin/bash
INDEX_NAME="test1"
echo "delete index just to be sure"
curl -XDELETE "http://localhost:9200/$INDEX_NAME/"; echo
echo "create new index"
curl -X PUT "http://localhost:9200/$INDEX_NAME/" -d '{
"index":{
"analysis":{
"analyzer":{
"analyzer1":{
"type":"custom",
"tokenizer":"standard",
"filter":[ "standard", "lowercase", "stop", "kstem", "ngram" ]
}
},
"filter":{
"ngram":{
"type":"ngram",
"min_gram":2,
"max_gram":15
}
}
}
}
}'; echo
echo "analyze something with our shiny new analyzer"
curl -XGET "localhost:9200/$INDEX_NAME/_analyze?analyzer=analyzer1&pretty=true" -d 'abcd'
echo "remove the created index"
curl -XDELETE "http://localhost:9200/$INDEX_NAME/"; echo
echo "create new index again with mapping"
curl -X PUT "http://localhost:9200/$INDEX_NAME/" -d '{
"index":{
"analysis":{
"analyzer":{
"analyzer1":{
"type":"custom",
"tokenizer":"standard",
"filter":[ "standard", "lowercase", "stop", "kstem", "ngram" ]
}
},
"filter":{
"ngram":{
"type":"ngram",
"min_gram":2,
"max_gram":15
}
}
}
},
"mappings": {
"product": {
"properties": {
"title": {
"type": "string",
"search_analyzer" : "analyzer1",
"index_analyzer" : "analyzer1"
}
}
}
}
}'; echo