我是NEST ElasticSearch的新手,并且有一个Class命名文档,如下所示
[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());
}
}
基本上我想将IndexAnalyzer应用于类Document中的Documents属性。但它没有用。在调试时,我注意到如果我使用下面的代码检查属性,则Mappings计数为零
var r = this.client.GetIndexSettings(i => i.Index(indexName));
任何帮助?
Manish
答案 0 :(得分:0)
检查索引的映射,如下所示:
http://10.0.0.11:9200/{index_name}/{mappingType}/_mapping?pretty
大多数情况下,映射被分析器的错误实现“杀死”。如果你能够提供你所拥有的完整示例,那将更容易为你提供帮助。