solr: function usage problem

2019-08-24 01:40发布

问题:

to solve a problem described at [question]: Solr: where to store additional information? i wrote a function termcnt(fieldname) which just count specific terms in document regarding specified fieldname.
Using solr admin page (http://localhost:8080/admin/form.jsp) in "Solr/Lucene Statement" I queried:

fq={!frange l=3 u=1000}termcnt(wc_text)

and got an error:

type Status report
message org.apache.lucene.queryParser.ParseException: Cannot parse 'fq={!frange l=3 u=1000}termcnt(wc_text)': Encountered " <RANGEEX_GOOP> "u=1000 "" at line 1, column 16. Was expecting: "}" ...
description The request sent by the client was syntactically incorrect (org.apache.lucene.queryParser.ParseException: Cannot parse 'fq={!frange l=3 u=1000}termcnt(wc_text)': Encountered " <RANGEEX_GOOP> "u=1000 "" at line 1, column 16. Was expecting: "}" ... ).

where is my mistake?

thank you

P.S. when I'm queering:

_val_:"termcnt(wc_text)"

my function is working properly...

P.P.S even with sum func i have the same results :(

fq={!frange l=3 u=1000}sum(2,3)

solr 3.2.0
lucene 3.2.0
(from maven repository)

stack trace (as requested):

1 jul 2011 9:33:39 org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: org.apache.lucene.queryParser.ParseException:   Cannot parse 'fq={!frange l=3 u=100000}termcnt(wc_text)': Encountered " <RANGEEX_GOOP> "u=100000 "" at line 1, column 16.
Was expecting:
"}" ...

at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:108)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:286)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:272)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1730)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse 'fq={!frange l=3 u=100000}termcnt(wc_text)': Encountered " <RANGEEX_GOOP> "u=100000 "" at line 1, column 16.
Was expecting:
"}" ...

at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211)
at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:80)
at org.apache.solr.search.QParser.getQuery(QParser.java:142)
at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:84)
... 21 more
Caused by: org.apache.lucene.queryParser.ParseException: Encountered " <RANGEEX_GOOP> "u=100000 "" at line 1, column 16.
Was expecting:
"}" ...

at org.apache.lucene.queryParser.QueryParser.generateParseException(QueryParser.java:1818)
at org.apache.lucene.queryParser.QueryParser.jj_consume_token(QueryParser.java:1700)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1510)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1309)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1266)
at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1226)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
... 24 more

1 jul 2011 9:33:39 org.apache.solr.core.SolrCore execute
INFO: [] webapp= path=/select params={explainOther=&fl=&indent=on&start=0&q=fq%3D{!frange+l%3D3+u%3D100000}termcnt(wc_text)&hl.fl=&qt=&wt=&fq=&rows=10&version=2.2} status=400 QTime=21 

回答1:

I believe the interface has changed somewhat since this was written--but your query

fq={!frange l=3 u=1000}sum(2,3)

seems to be written correctly. You might try to url encode it, like

fq=%7B!frange+l%3D3+u%3D1000%7Dsum(2%2C3)

But I have a feeling this issue is solved just from newer versions of Solr and the admin panel.



标签: solr