显示字段数据类型token_count的值

时间:2018-10-03 10:01:06

标签: elasticsearch

我有以下映射:

   "fullName" : {
            "type" : "text",
            "norms" : false,
            "similarity" : "boolean",
            "fields" : {
              "raw" : {
                "type" : "keyword"
              },
              "terms" : {
                "type" : "token_count",
                "analyzer" : "standard"
              }
            }
          }

我想显示条件值字段。当我执行以下操作时,我得到的是fullName而不是terms值

GET /_search
{"_source": ["fullName","fullName.terms"], 
    "query": {
        "bool" : {
            "must" : {
                "script" : {
                    "script" : {
                        "source": "doc['fullName.terms'].value != 3,
                        "lang": "painless"
                     }
                }
            }
        }
    }
}

我如何得到它?

1 个答案:

答案 0 :(得分:0)

您需要配置存储令牌数量-Here documentation

您应该修改映射:

WebElement bldgs=Fn_GetWebElement(CreateSSIObject.getProperty("Bldgselect"));
Select  Bldg_select=new Select(bldgs);

List<WebElement> dropdownvalues = Bldg_select.getOptions();

int count=dropdownvalues.size();
System.out.println("Toatl number of values are :"+count);

    for(int i=1;i<26;i++)
    {       
        if(dropdownvalues.get(i).isEnabled())
        {
             dropdownvalues.get(i).click();
             System.out.println("Not Working :"+i);
        }
    }

然后检索您需要在查询中明确要求存储值的值:(here documentation

"terms" : {
    "type" : "token_count",
    "analyzer" : "standard",
    "store": true
}