예, 이것을 수행하는 방법은 multi_fields
입니다. 분석 및 검색을 위해 사용될 수있는 전방 Elasticsearch 5.0
, 두 개의 유형으로
string
field types were split out,
text
필드 유형, 분석되지 않고, 정렬 집계하고 정확한 값 일치하는 용도에 적합한
keyword
필드 타입. Elasticsearch 5.0에서 동적 매핑으로
(즉 Elasticsearch 문서 속성에 매핑되어야하는 유형 추론하자) 즉 "키워드"의 서브 필드로, string
속성이 text
필드 유형에 매핑 된 JSON을 keyword
필드 유형으로 매핑되고 설정은 ignore_above:256
입니다.
NEST 5.x 자동 매핑을 사용하면 POCO의 string
속성이 Elasticsearch의 동적 매핑과 동일한 방식으로 자동 매핑됩니다 (예 : 다음 문서
public class Document
{
public string Property { get; set; }
}
automapping it
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var defaultIndex = "default-index";
var connectionSettings = new ConnectionSettings(pool)
.DefaultIndex(defaultIndex);
var client = new ElasticClient(connectionSettings);
client.CreateIndex(defaultIndex, c => c
.Mappings(m => m
.Map<Document>(mm => mm
.AutoMap()
)
)
);
주어진 이제
Field(f => f.Property.Suffix("keyword")
를 사용하여 정렬
property
을 사용할 수 있습니다
{
"mappings": {
"document": {
"properties": {
"property": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
}
}
}
생산하고 있습니다. 더 많은 예제를 보려면 Field Inference을보십시오.
keyword
필드 유형에는 기본적으로 doc_values
이 사용됩니다. 즉, 컬럼 시간 데이터 구조가 인덱스 시간에 작성되며 이는 효율적인 정렬 및 집계를 제공합니다.
인덱스 작성시 사용자 정의 분석기를 추가하려면, 우리는 이전과 오토,하지만 우리가
{
"settings": {
"analysis": {
"analyzer": {
"lowercase_analyzer": {
"type": "custom",
"filter": [
"standard",
"lowercase",
"trim"
],
"tokenizer": "keyword"
}
}
}
},
"mappings": {
"document": {
"properties": {
"property": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "lowercase_analyzer"
}
}
}
}
}
생산과
.Properties()
client.CreateIndex(defaultIndex, c => c
.Settings(s => s
.Analysis(a => a
.Analyzers(aa => aa
.Custom("lowercase_analyzer", ca => ca
.Tokenizer("keyword")
.Filters(
"standard",
"lowercase",
"trim"
)
)
)
)
)
.Mappings(m => m
.Map<Document>(mm => mm
.AutoMap()
.Properties(p => p
.Text(t => t
.Name(n => n.Property)
.Analyzer("lowercase_analyzer")
.Fields(f => f
.Keyword(k => k
.Name("keyword")
.IgnoreAbove(256)
)
)
)
)
)
)
);
에 대한 매핑을 제어하려는 분야에 대한 재정의를 제공 할 수 있습니다