Spring数据弹性搜索嵌套字段和NativeSearchQueryBuilder.withFields

Spring数据弹性搜索嵌套字段和NativeSearchQueryBuilder.withFields,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,使用NativeSearchQueryBuilder.withFields(…)方法时,我似乎无法获取要返回的嵌套字段 这是我的父对象: @Document(indexName = "inventory") public class Inventory { @Id private String id; @Field(type=FieldType.String) private String name; @Field(type=FieldType.Nested, index=F

使用NativeSearchQueryBuilder.withFields(…)方法时,我似乎无法获取要返回的嵌套字段

这是我的父对象:

@Document(indexName = "inventory")
public class Inventory
{
  @Id
  private String id;
  @Field(type=FieldType.String)
  private String name;
  @Field(type=FieldType.Nested, index=FieldIndex.not_analyzed, store=true)
  private List<Model> models;
}
如果删除withFields(…)设置,则返回:

{
   "id":"d5f82880-15bc-45ed-8abb-ff97d0e45da9",
   "name": "Cool Beans",
   "models": [
     {
       "model" : "foo",
       "series" : ["bar"]
     }
   ]
}
我试过模型,模型,模型系列,模型系列。我无法使用NestedFields处理withFields


有什么想法吗?

我对弹性搜索字段的理解不正确。拉胡洛克给我通风报信了

withFields与源筛选不同

因此,我有效地告诉Spring Data ES这样做:

curl localhost:9200/inventory/_search?pretty=true -d '
{
  "fields" : ["models.series"],
  "query" : {
     "match" : {"name" : "cool"}
  }
}'
当这是我想要的

curl localhost:9200/inventory/_search?pretty=true -d '
{
  "_source" : ["models.series"],
  "query" : {
     "match" : {"name" : "cool"}
  }
}'
在我开始添加嵌套字段之前,withFields方法一直适用于我所做的工作。我正在使用的Spring Data ES的当前实现不支持源代码过滤


源代码筛选最近刚刚添加到Spring Data ES 2.0.0中。RC1

当您在查询中指定
字段时,它不会在响应中返回
源代码。只有
字段
出现在获取记录值的点击中。我认为你正在寻找价值的来源
{
   "id":"d5f82880-15bc-45ed-8abb-ff97d0e45da9",
   "name": "Cool Beans",
   "models": [
     {
       "model" : "foo",
       "series" : ["bar"]
     }
   ]
}
curl localhost:9200/inventory/_search?pretty=true -d '
{
  "fields" : ["models.series"],
  "query" : {
     "match" : {"name" : "cool"}
  }
}'
curl localhost:9200/inventory/_search?pretty=true -d '
{
  "_source" : ["models.series"],
  "query" : {
     "match" : {"name" : "cool"}
  }
}'