समस्या:Elasticsearch जावा एपीआई addMapping() और setSettings() उपयोग
json फ़ाइल का उपयोग करते हुए एक json फ़ाइल से एक सूचकांक बनाने के लिए कैसे सूचकांक de_brochures
के लिए एक परिभाषा में शामिल है। यह एक विश्लेषक de_analyzer
को संबंधित फ़िल्टर द्वारा उपयोग किए जाने वाले कस्टम फ़िल्टर के साथ भी परिभाषित करता है। जैसा कि जेसन कर्ल और सेंस के साथ काम करता है, मुझे लगता है कि जावा जावा एपीआई के साथ काम करने के लिए मुझे इसके सिंटैक्स को अनुकूलित करना होगा।
मैं XContentFactory.jsonBuilder() का उपयोग नहीं करना चाहता क्योंकि जेसन एक फ़ाइल से आता है! indexname यह इस से एक सूचकांक पैदा नहीं करता
PUT साथ नब्ज का उपयोग /:
मैंने अपने मानचित्रण नहीं बना और सेटिंग सेट करने के लिए निम्न json फ़ाइल है।
{
"mappings": {
"de_brochures": {
"properties": {
"text": {
"type": "string",
"store": true,
"index_analyzer": "de_analyzer"
},
"classification": {
"type": "string",
"index": "not_analyzed"
},
"language": {
"type": "string",
"index": "not_analyzed"
}
}
}
"settings": {
"analysis": {
"filter": {
"de_stopwords": {
"type": "stop",
"stopwords": "_german_"
},
"de_stemmer": {
"type": "stemmer",
"name": "light_german"
}
},
"analyzer": {
"de_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"de_stopwords",
"de_stemmer"
]
}
}
}
}
}
ऊपर addMapping() के साथ काम नहीं किया जैसा कि अकेले मैं इसे दो अलग फ़ाइलों में विभाजित करने की कोशिश की (मुझे एहसास हुआ कि मैं "mappings":
और "settings":
हिस्से को हटाने के लिए किया था):
------ Mapping json ------
{
"de_brochures": {
"properties": {
"text": {
"type": "string",
"store": true,
"index_analyzer": "de_analyzer"
},
"classification": {
"type": "string",
"index": "not_analyzed"
},
"language": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
------- Settings json --------
{
"analysis": {
"filter": {
"de_stopwords": {
"type": "stop",
"stopwords": "_german_"
},
"de_stemmer": {
"type": "stemmer",
"name": "light_german"
}
},
"analyzer": {
"de_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"de_stopwords",
"de_stemmer"
]
}
}
}
}
यह मेरा जावा कोड लोड करने और जेसन को जोड़ने/सेट करने के लिए है।
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(index);
// CREATE SETTINGS
String settings_json = new String(Files.readAllBytes(brochures_mapping_path));
createIndexRequestBuilder.setSettings(settings_json);
// CREATE MAPPING
String mapping_json = new String(Files.readAllBytes(brochures_mapping_path));
createIndexRequestBuilder.addMapping("de_brochures", mapping_json);
CreateIndexResponse indexResponse = createIndexRequestBuilder.execute().actionGet();
मैपिंग फ़ाइल की संरचना के बारे में कोई अधिक शिकायत नहीं है लेकिन अब यह त्रुटि के साथ विफल:
Caused by: org.elasticsearch.index.mapper.MapperParsingException: Analyzer [de_analyzer] not found for field [text]
कृपया प्रश्न का समाधान जोड़ें न करें। समाधान प्रश्न नहीं हैं। समाधान जवाब हैं। जब आप समाधान पाते हैं तो स्टैकओवरफ्लो आपके प्रश्नों का उत्तर देने का प्रोत्साहित करता है। लेकिन कृपया इसे एक जवाब में करें। समाधान को शामिल करने के लिए सवाल को संपादित करना सिर्फ पाठकों को भ्रमित करता है। धन्यवाद! – Vogel612