我正在使用ElasticSearch(1.4.4)运行单个节点,并且我有两个索引相同文档的索引。唯一的区别在于分片数量:
当我使用Java API运行100个不同查询的测试时,每个索引都会得到不同的结果。我已经尝试过对它们使用DFS Query Then Fetch,但我仍然得到不同的结果。
我想知道发生了什么。我不确定elasticsearch如何执行查询以获得不同的结果。
更新
这些是我的索引的设置和映射:
"settings": {
"number_of_shards" : 1, // or 5 for the other index
"number_of_replicas" : 0,
"analysis": {
"filter": {
"worddelimiter": {
"type": "word_delimiter"
}
},
"analyzer": {
"custom_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"worddelimiter"
],
"tokenizer": "standard"
}
}
}
}
"mappings": {
"faq": {
"properties": {
"answer": {
"type": "string",
"analyzer": "custom_analyzer"
},
"answer_id": {
"type": "long"
},
"path": {
"type": "string",
"analyzer": "custom_analyzer"
},
"question": {
"type": "string",
"analyzer": "custom_analyzer"
}
}
}
}
这是查询:
client.prepareSearch(index)
.setTypes(type)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.multiMatchQuery(inputText, "questions","answer^2","paths")
.setSize(BUFFER_SIZE)
.setFrom(i * BUFFER_SIZE)
.execute()
.actionGet();