java - lucene setting negative scores to certain query terms -


q1="apple^0.1 juice^0.85"  q2="apple^-0.1 juice^0.85" 

q1 works perfectly. if set negative weight "apple" in q2, throws lexical error. know how fix in way without using .setboost() method?

caused by: org.apache.lucene.queryparser.classic.tokenmgrerror: lexical error @ line 1, column 7.  encountered: "-" (45), after : ""     @ org.apache.lucene.queryparser.classic.queryparsertokenmanager.getnexttoken(queryparsertokenmanager.java:1129)     @ org.apache.lucene.queryparser.classic.queryparser.jj_consume_token(queryparser.java:562)     @ org.apache.lucene.queryparser.classic.queryparser.term(queryparser.java:333)     @ org.apache.lucene.queryparser.classic.queryparser.clause(queryparser.java:247)     @ org.apache.lucene.queryparser.classic.queryparser.query(queryparser.java:171)     @ org.apache.lucene.queryparser.classic.queryparser.toplevelquery(queryparser.java:160)     @ org.apache.lucene.queryparser.classic.queryparserbase.parse(queryparserbase.java:118) 

here code relevant this:

queryparser parser = new queryparser( "content", new keywordanalyzer() );  query q = parser.parse(  querystr ); //q1 or q2 


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -