의 특정 필드를로드하면 설명서에 전체 문서 대신 필드의 하위 집합을 반환 할 수 있음이 나타납니다. 여기 내 코드 :Elasticsearch Nest 쿼리
var result = client.Search<MyObject>(s => s
.Fields(f => f.Title)
.Query(q => q
.QueryString(qs => qs
.OnField("title")
.Query("the"))));
'제목'필드에서 'the'단어를 검색하고 'title'을 (를) 반환하고 싶습니다. 내 result.Documents 객체에는 각각 null 인 10 개의 객체가 포함되어 있습니다.
내가 원하는 값을 참조 할 수 있지만 검색 응답에 깊은입니다 : result.Hits [0] .Fields.FieldValues [0] ...
이 얻을 수있는 더 좋은 방법이 'title'필드 목록이 반환 되었습니까? (절단) 데이터에 대한 내 매핑이 ...
{
"myidex": {
"mappings": {
"myobject": {
"properties": {
"title": {
"type": "string"
},
"artists": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed",
"analyzer": "fullTerm"
},
"name": {
"type": "string",
"index": "not_analyzed",
"analyzer": "fullTerm"
}
}
}
}
}
}
}
}
내 클래스 객체는 다음과 같이되어있다
:
[Table("MyTable")]
[Serializable]
[ElasticType(Name="myobject")]
public class MyObject
{
[ElasticProperty]
public string Title { get; set; }
[JsonIgnore]
public string Artistslist { get; set; }
[ElasticProperty(Analyzer = "caseInsensitive")]
public List<Person> Artists { get; set; }
}
[Serializable]
public class Person
{
[ElasticProperty(Analyzer = "fullTerm", Index = FieldIndexOption.not_analyzed)]
public string Name { get; set; }
[ElasticProperty(Analyzer = "fullTerm", Index = FieldIndexOption.not_analyzed)]
public string Id { get; set; }
}
Artistslist 내 데이터 소스 (SQL)에서 유래 한 후 데이터를 인덱싱하기 전에 새 List 객체로 파싱합니다.
어떤 NEST 버전을 사용하고 있습니까? –
nest 및 elasticsearch.net의 시험판 (누겟을 통해). 나는 그것이 1.0.0 beta1이라고 믿는다. – bigerock
'result.Documents' 객체가 null 인 경우 매핑 문제 일 수 있습니다. MyObject 클래스 정의를 질문에 추가 할 수 있습니까? –