簡體   English   中英

ElasticProperty-索引在Nest中不起作用-ElasticSearch

[英]ElasticProperty - Indexing not working in Nest - ElasticSearch

我有如下配置的索引數據。 我使用ES 1.1.1和Nest 1.0.0-beta1。

Analyzer

{
 "index": {
   "analysis": {
    "analyzer": {
     "allwords": {
      "type": "custom",
      "tokenizer": "allwords_tokenizer",
      "filter": [
        "asciifolding",
        "lowercase",
        "my_stop",
        "standard"
      ]
    }
  },
  "tokenizer": {
    "allwords_tokenizer": {
      "type": "keyword",
      "max_token_length": 255
    }
  },
  "filter": {
    "my_stop": {
      "type": "stop",
      "stopwords": "_none_"
    }
  }
}
}
}

Mapping

{
 "properties": {
 "name": {
  "type": "string",
  "fields": {
    "raw": {
      "type": "string",
      "analyzer": "allwords"
     }
    }
   }
  }
 }

我的ES對象是

[ElasticType(Name = "profile",IdProperty = "Id")]
public class ES_Profile
{
    public string Id { get; set; }

    [ElasticProperty(Name = "name.raw", Type = FieldType.string_type, SearchAnalyzer =   "allwords", Store = false)]
    public string name_raw { get; set; }

    public string name { get; set; }
}

問題是索引。 沒有

 [ElasticProperty(Name = "name.raw", Type = FieldType.string_type, SearchAnalyzer =   "allwords", Store = false)]
    public string name_raw { get; set; }

它可以完美地工作並為數據建立索引,但是當我將其與“ name_raw”一起使用時,它會失敗。

我收到以下答復,無法理解問題。

{
    StatusCode: 200, 
    Method: POST, 
    Url: http://127.0.0.1:9200/hzmt_x/profile/1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D, 
    Request: {"id": "1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D", "name": "My Name"  
 }, 
Response: {"_index":"hzmt_x","_type":"profile","_id":"1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D","_version":8,"created":false}}

當我獲得索引設置時,我得到了

{
hzmt_x: {
 settings: {
  index: {
    uuid: ahOhgj17QOyCVFcO2aRf1A
    analysis: {
      filter: {
        my_stop: {
          type: stop
          stopwords: _none_
        }
    }
    analyzer: {
      allwords: {
        type: custom
        filter: [
        asciifolding
        lowercase
        my_stop
        standard
        ]
        tokenizer: allwords_tokenizer
      }
      allwords_tokenizer: {
        type: keyword
        max_token_length: 255
      }
    }
    }
  }
}
}
}

對於映射,我得到了

     {
   hzmt_x: { 
     mappings: { 
       profile: {
         properties: { 
           id: { 
             type: string
           }
           name: { 
             type: string
             fields: {
               raw: { 
                 type: string
                 analyzer: allwords
               }
             }
           }
         }
       }
     }
     }
     }

“ name_raw”是一個索引時間分析字段,因此我認為應該沒有問題,但是我有一個。

我該怎么辦? 你有什么建議嗎?

謝謝,奧古斯

您使用的是哪個版本的Nest?更新到最新版本。下面的代碼對我有用。

  var rep = client.CreateIndex("test", c => c

                   .AddMapping<object>(m => m
                       .Properties(props => props
                           .String(ps => ps.Name(""name_raw").IndexAnalyzer("keyword"))

                           )));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM