현재 나는 elasticsearch로 작업 중이며 클러스터의 문서를 "검색"하려고합니다. 이것은 내가 예상 한 결과를 얻지 못하는 곳입니다. 나는 그들이 모두 검색어 키워드 "te"와 일치해야하므로 4 개의 결과가 반환되기를 바랬습니다. GET _searchElasticSearch가 올바른 결과를 반환하지 않습니다.
{
"query": {
"filtered" : {
"filter" : {
"term" : {
"source_id" : 1
}
},
"query": {
"bool" : {
"must" : {
"term" : { "_all" : "te" }
}
}
}
}
},
"sort": [
{
"date": {
"order": "desc"
}
}
],
"from": 0,
"size": 5
}
이 쿼리를 실행할 때 나는 (내가 4를 기대하면서) 단지 2 개의 결과만을 얻습니다. 다음 "대상"필드와 나는 4 개 결과를 얻을 부분 : 나는 "{} 쿼리를"제거하면 쿼리 당
{
"subject": ["Testbericht"]
"subject": ["test"]
"subject": ["Testbericht"]
"subject": ["Test to myself"]
}
는 쿼리의 필터는 특정 소스에서 결과를 반환하는 것입니다 (1 소스를).
는내 매핑 :
{
"messages": {
"mappings": {
"message": {
"_id": {
"index": "not_analyzed"
},
"properties": {
"addresses": {
"type": "nested",
"properties": {
"displayname": {
"type": "string"
},
"email": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"body": {
"type": "string"
},
"date": {
"type": "date",
"format": "dateOptionalTime"
},
"files": {
"type": "nested",
"properties": {
"size": {
"type": "long"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"folders": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
}
}
},
"size": {
"type": "long"
},
"source_id": {
"type": "integer"
},
"subject": {
"type": "string"
}
}
}
}
}
}
내가 _all = 검색하려고 할 때 얻을 결과 "테"
{
"subject": ["test"]
"subject": ["Testbericht"]
}
삽입 문서 :
// PHP client from https://github.com/elasticsearch/elasticsearch-php
// $this->search = new Elasticsearch\Client();
// $id is an unique string
// $attributes is an array of the attributes
public function insert($id, array $attributes)
{
$params = [
'index' => self::INDEX,
'type' => self::TYPE,
'id' => $id,
'body' => [
'source_id' => $attributes['source_id'],
'date' => $attributes['date']->format(DateTime::ISO8601),
'size' => $attributes['size'],
'subject' => $attributes['subject'],
'body' => $attributes['body'],
'addresses' => $attributes['addresses'],
'files' => $attributes['files'],
'folders' => $attributes['folders'],
],
];
try
{
$this->search->index($params);
return true;
}
catch(Exception $e)
{
throw new Exception($e->getMessage());
}
return false;
}
u 쿼리를 실행할 때 얻을 수있는 두 가지 결과는 무엇입니까? 또한 인덱싱하는 동안 분석기가 사용한 것은 무엇입니까? – keety
귀하는 귀하의 질의를 게시했습니다. 매핑도 게시하십시오. 더 많은 정보가 없다면 나는 그것이 현재 case-sensetive로 매핑되어 있다고 생각할 것입니다. – Brandon
나는 특정 분석기를 사용하지 않고 있습니까? – Floris