lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Hebbrecht <jochenhebbre...@gmail.com>
Subject Searching for a search string containing a literal slash doesn't work with QueryParser
Date Mon, 01 Oct 2012 12:59:15 GMT
Hi,

I'm currently trying to search on the following search string in my Lucene
index: "2012/0.124.323".
The java code to search for ('value' is my search string)

----
QueryParser queryParser = new QueryParser(Version.LUCENE_36, field, new
StandardAnalyzer(Version.LUCENE_36));
queryParser.setAllowLeadingWildcard(true);
return queryParser.parse(value);
----

This returns a query result: "2012" "0.124.323". QueryParser is replacing
the forward slash by a space.
I tried escaping the "/" with a backslash "\", but this doesn't work either.

Maybe required to fully understand my scenario. I have the following import
XML:

---
...
<TEXT l="963" t="826" r="1391" b="870">Vervaldag </TEXT>
<TEXT l="963" t="826" r="1391" b="870">17/07/12</TEXT>
<TEXT l="2100" t="833" r="2275" b="871">09/07/12</TEXT>
<TEXT l="42" t="871" r="338" b="907">2012/0.124.323</TEXT>
<TEXT l="1478" t="938" r="1673" b="978">Kapitaals</TEXT>
...
---

I get all TEXT values with an XPath expression and I index them as:

---
XPathExpression expr = xpath.compile("//TEXT");
Object result = expr.evaluate(document, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
    doc.add(new org.apache.lucene.document.Field("IMAGE",
nodes.item(i).getFirstChild().getNodeValue(), Store.NO, Index.ANALYZED));
}
---

I'm using the StandardAnalyzer.

What is the best way to solve my issue? Do I need to switch from Analyzer?
Do I have to use something else then QueryParser? ...
I also want to support searching on 2012/0.*, so I cannot only use
TermQuery ...

Kind regards,
Jochen

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message