Py学习  »  Elasticsearch

如何在elasticsearch中添加文档时引用多个字段

mehdi delmaghani • 5 年前 • 874 次点击  

我创建了这个mappaing的类“document”。但是我不知道如何访问属性字段。

这是我的映射(摘要):

"mappings": {
      "document": {
        "properties": {

          "baseUniqueID": {
            "type": "keyword"
          },
          "description": {
            "type": "text",
            "fields": {
              "en": {
                "type": "text",
                "analyzer": "english"
              },
              "fa": {
                "type": "text",
                "analyzer": "nofapersian"
              },
              "fr": {
                "type": "text",
                "analyzer": "french"
              }
            }
          },
          "documentDate": {
            "type": "date"
          },
          "documentType_Id": {
            "type": "keyword"
          },
          "id": {
            "type": "long"
          }

        }
      }
    }

文档类:

public class Document : BaseInt32KeyEntity
    {
        public string BaseUniqueID{ get; set; }

        public int? Weight { get; set; }

        public DateTime DocumentDate { get; set; }

        public string Description { get; set; }

        public int DocumentType_Id { get; set; }
    }
}

如何使Document对象只填充所需的字段(在这个示例description.en中),然后使用IndexDocument将其添加到Elasticsearch?像这样的:

Document doc = new Document();
doc.Description.en = "This is some description";
ElasticClient.IndexDocument(doc);

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56366
 
874 次点击  
文章 [ 1 ]  |  最新文章 5 年前