我是 NEST ElasticSearch 的新手,并且有一个名为文档的类,如下所示
[ElasticType(Name = "EnterpriseSearch.Document")]
public class Document
{
public Document()
{
}
[ElasticProperty(Type = FieldType.Integer, Index = FieldIndexOption.NotAnalyzed)]
public int DocumentId { get; set; }
[ElasticProperty(Type = FieldType.String, Index = FieldIndexOption.NotAnalyzed)]
public string Source { get; set; }
[ElasticProperty(Type = FieldType.String, Index = FieldIndexOption.NotAnalyzed)]
public string Name { get; set; }
[ElasticProperty(Type = FieldType.String, Index = FieldIndexOption.Analyzed, IndexAnalyzer = "snowballstopAnalyzers", TermVector = TermVectorOption.WithPositionsOffsets)]
public string Documents { get; set; }
}
我正在创建索引并尝试使用以下代码对其进行映射。
public void CreateDocumentIndex(string indexName = null)
{
if (!this.client.IndexExists(indexName).Exists)
{
IndexSettings settings = GetIndexSettings();
this.client.CreateIndex(indexName, c => c
.InitializeUsing(settings)
.AddMapping<Document>
(m => m.Properties(ps => ps.String(a => a.Name(o => o.Documents)))));
this.client.Map<Document>(p => p.MapFromAttributes());
}
}
基本上,我想应用索引分析器来属性类文档中的文档。但它不起作用。调试时,我注意到如果我使用以下代码检查属性,映射计数为零
var r = this.client.GetIndexSettings(i => i.Index(indexName));
有什么帮助吗?
马尼什
像这样检查索引的映射:
http://10.0.0.11:9200/{index_name}/{mappingType}/_mapping?pretty
大多数情况下,映射被分析器的错误实现"杀死"。如果你能把你拥有的完整例子,它会更容易帮助你。