queryContext - 用数字过滤neo4j / lucene [英] queryContext - filtering with numbers neo4j/lucene

查看:155
本文介绍了queryContext - 用数字过滤neo4j / lucene的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用数字范围在neo / lucene中过滤通配符查询。
我想搜索以rob开始,年龄> 20的关键演员的所有节点(文档):

  WildcardQuery luceneQuery = new WildcardQuery(新术语(actor,rob *)); 
QueryContext qx = new QueryContext(luceneQuery)
.numericRange(age,20,null)
.sortNumeric(age,true);
IndexHits< Node> hits = lucene.query(qx);

一旦我添加数字范围,wildCard查询不起作用,它只能按数字范围排序。
是否可以结合通配符和数字?



谢谢,
Daniele

解决方案

我怀疑你想使用一个布尔查询来结合WildcardQuery和数字范围查询。 (我通常使用QueryParser,而不是手动构建查询)。

对于您的示例查询,QueryParser语法如下所示:

  + actor:rob * + age:{20至123} 

其中 +年龄:{20至123} 要求年龄> 20且年龄< 123(最古老的文献记载的人活到122)。 +运算符强制这两个条款出现在文档中。


I'm trying to filter a wildcard query in neo/lucene using numeric range. I want to search for all nodes (documents) having key "actor" starting with "rob" and age > 20:

WildcardQuery luceneQuery  = new WildcardQuery( new Term("actor", "rob*" ));
QueryContext qx = new QueryContext(luceneQuery)
            .numericRange("age", 20, null)
                .sortNumeric("age", true);      
IndexHits<Node> hits = lucene.query(qx);

Once I add numeric range the wildCard query does not works, it only orders by numeric range. Is it possible to combine both wildcard and numeric?

Thanks, Daniele

解决方案

I suspect you want to use a BooleanQuery to combine the WildcardQuery with the numeric range query. (I normally use QueryParser, myself, rather than building the queries by hand.)

For your example query, the QueryParser syntax would look like:

+actor:rob* +age:{20 TO 123}

where +age:{20 TO 123} asks for age > 20 AND age < 123 (the oldest well-documented person lived to 122). The "+" operators force both of those terms to occur in the document.

这篇关于queryContext - 用数字过滤neo4j / lucene的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆