2016-05-12 12 views
0

インデックスに特定のタイプのドキュメントのみを返すオートコンプリートを提供する機能が必要です。弾性検索NEST V2完了コンテキストマッピング

コンテキストが適用されていない状態でオートコンプリート提案が動作しています。しかし、私がコンテキストを試してマップすると失敗します。

ここに私が持っているマッピングがあります。

.Map<MyType>(l => l 
.Properties(p => p 
    .Boolean(b => b 
     .Name(n => n.IsArchived) 
    ) 
    .String(s => s 
     .Name(n => n.Type) 
     .Index(FieldIndexOption.No) 
    ) 
    .AutoMap() 
    .Completion(c => c 
     .Name(n => n.Suggest) 
     .Payloads(false) 
     .Context(context => context 
      .Category("type", cat => cat 
       .Field(field => field.Type) 
       .Default(new string[] { "defaultType" }) 
      ) 
     ) 
    ) 
) 

インテリセンスやビルドにエラーがないため、私が間違っていることを確認できません。

+0

NEST 2.xののバージョンになり、次の

public class MyType { public bool IsArchived { get; set;} public string Type { get; set;} public CompletionField<object> Suggest { get; set;} } client.Map<MyType>(l => l .AutoMap() .Properties(p => p .Boolean(b => b .Name(n => n.IsArchived) ) .String(s => s .Name(n => n.Type) .Index(FieldIndexOption.No) ) .Completion(c => c .Name(n => n.Suggest) .Context(context => context .Category("type", cat => cat .Field(field => field.Type) .Default("defaultType") ) ) ) ) ); 

のようになりますか? Elasticsearchのどのバージョンを実行していますか? –

+0

NEST 2.1.0およびElasticsearch 2.3.0 –

+0

@RussCam ?????? –

答えて

1

The Context Suggester mappingは正しいものではなく、そのままコンパイルされません。 AutoMap()PropertiesDescriptor<T>のメソッドではありませんが、PutMappingDescriptor<T>のメソッドです。 the completion suggester mapping that is used as part of the integration testsを見てください。これは、次のマッピング

{ 
    "properties": { 
    "isArchived": { 
     "type": "boolean" 
    }, 
    "type": { 
     "type": "string", 
     "index": "no" 
    }, 
    "suggest": { 
     "type": "completion", 
     "context": { 
     "type": { 
      "type": "category", 
      "path": "type", 
      "default": [ 
      "defaultType" 
      ] 
     } 
     } 
    } 
    } 
} 
+0

乾杯。私の例では、私は複数のタイプにマップしようとしていたとは言いませんでした。私は、それぞれのタイプに対して異なるデフォルト値を設定しようとしていました。これは失敗した場所です。 https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#field-conflicts –