ElasticSearch RestHighLevelClient提供的结果不准确

时间:2019-02-01 15:24:56

标签: elasticsearch

我在SpringBoot中使用ES。我尝试使用以下代码段搜索结果。

  SearchRequest searchRequest = new SearchRequest("businesses");
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    searchSourceBuilder.query(QueryBuilders.termQuery("name", "Microsoft"));
    SearchResponse response = highLevelClient.search(searchRequest, RequestOptions.DEFAULT);
    SearchHit[] searchHit = response.getHits().getHits();

当我遍历“ searchHits”时,没有一个名称与“ Microsoft”匹配。它总是返回一些其他名称。另外,其他名称的列表也是一致的evrytime。代码有什么问题吗?

1 个答案:

答案 0 :(得分:0)

在文档映射中,Flex( direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Flexible(child: Text('10%'), flex: 0, fit: FlexFit.tight,), SizedBox(width: 8.0), Flexible( flex: 1, fit: FlexFit.loose, child: FittedBox( fit: BoxFit.scaleDown, child: Text( 'Demo text. Demo text. Demo text. Demo text. Demo text.', textAlign: TextAlign.start ), ) ) ], ) 字段的类型应为name。我猜您没有明确设置它,默认情况下它设置为keyword