如何在Google AppEngine中搜索小于或等于的数字字段?

时间:2013-11-08 20:47:51

标签: java google-app-engine google-search-api

这些查询不起作用:

INFO: Searching with query:  year:(<=2008 OR  2011) 
INFO: Searching with query:  year:(<=2008)

代码

    log.info("Searching with query: " + q);
    try {
        Results<ScoredDocument> results = getIndex().search(q);

异常

INFO: Searching with query:  year:(<=2008 OR  2011) 
line 1:7 no viable alternative at input '<='
Nov 08, 2013 3:36:03 PM org.apache.struts2.dispatcher.Dispatcher error
SEVERE: Exception occurred during processing request: Unable to parse query:  year:(<=2008 OR  2011) 
com.google.appengine.api.search.SearchQueryException: Unable to parse query:  year:(<=2008 OR  2011) 
at com.google.appengine.api.search.checkers.QueryChecker.checkQueryParses(QueryChecker.java:44)
at com.google.appengine.api.search.checkers.QueryChecker.checkQuery(QueryChecker.java:28)
at com.google.appengine.api.search.Query$Builder.setQueryString(Query.java:91)
at com.google.appengine.api.search.Query$Builder.build(Query.java:107)
at com.google.appengine.api.search.IndexImpl.searchAsync(IndexImpl.java:378)
at com.google.appengine.api.search.IndexImpl.search(IndexImpl.java:479)

版本

应用服务引擎的API-1.0-SDK-1.8.6.jar

参考

https://developers.google.com/appengine/docs/java/search/query_strings

1 个答案:

答案 0 :(得分:2)

看起来语法错误。根据您提供的参考,自

"weather=stormy" "weather: stormy"是等效的,请尝试:

"year<=2008 OR year=2011"

(假设这是你在你的例子中的意图)。