Milan Todorovic
Milan Todorovic

Reputation: 440

Exist DB lucene fuzzy search Issue

I have an issue with running an XQuery on eXist-db. I have an application that runs on Tomcat and sends queries to eXist-db, to find certain files. The query that is generated and sent is like this (I use ~ for fuzzy search):

for $doc in collection('/db')//document/sender[ft:query(.,'test~')] 
let $score := ft:score($doc)
order by $score descending
return
    base-uri($doc)

and I get the following error on the test server:

 org.exist.xquery.XPathException: exerr:ERROR Syntax error in Lucene query
 string: Cannot parse 'test~': Encountered " <FUZZY_SLOP> "~ "" at line 1, column 10.
Was expecting one of:
    <EOF>
    <AND> ...
    <OR> ...
    <NOT> ...
    "+" ...
    "-" ...
    <BAREOPER> ...
    "(" ...
    "*" ...
    "^" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    <REGEXPTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...

However, when I run the same query on my local machine, I do not get that error and instead I get the expected results. What am I missing?

Upvotes: 0

Views: 144

Answers (1)

adamretter
adamretter

Reputation: 3517

I fear that there is some very subtle difference between the query that your application is sending to eXist-db, and the query when you run it on a local eXist-db instance.

I also made a couple minor cleanups to your query above.

Upvotes: 1

Related Questions