elasticsearch 过滤器使用问题求大神

colie_li 2015-04-19 04:13:30
通过 界面可以看到数据

过滤器写法:


public void search04() {
FilterBuilder filter =FilterBuilders.prefixFilter("name", "张三");
SearchResponse res = client.prepareSearch("test4").setTypes("test04")
.execute().actionGet();
SearchHits shs = res.getHits();
System.out.println("总共有数据:" + shs.getHits().length);
for (SearchHit it : shs) {
System.out.println(it.getSource());
}
}

查出来数据怎么是0条呢 求大神解答,

...全文
263 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
I am not a user of elasticsearch java library, so I can't tell if the issue you have is in the source. That has been said, since you didn't post your mapping configuration, there is no way to help from that aspect either. the rule of thumb for filter in terms of lucene config is that those fields are meant to be used for filter should have index: not_analyzed. This will prevent lucene from analyzing the text in this field so they will be left as they are. Keep in mind that filter is not a query. The term you set in filter will always be against the whole text in the selected fields.

2,760

社区成员

发帖
与我相关
我的任务
社区描述
搜索引擎的服务器通过网络搜索软件或网络登录等方式,将Internet上大量网站的页面信息收集到本地,经过加工处理建立信息数据库和索引数据库。
社区管理员
  • 搜索引擎技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧