Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshoot Java Lucene ignoring Field

Tags:

java

lucene

We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:

// Add market_local to index
contactDocument.add(
    new Field(
        "market_local"
        , StringUtils.objectToString(
            currClip.get(
                "market_local"
            )
        )
        , Field.Store.YES
        , Field.Index.UN_TOKENIZED 
    )
);

Running a query ( * ) against the index will return the following results:

Result 1:
    title: Foo Bar
    market_local: Local

Result 2:
    title: Bar Foo
    market_local: National

Running a targeted query:

+( market_local:Local )

won't find any results.

I realize this is a highly specific question, I'm just trying to get information on where to start debugging this issue, as I'm a Lucene newbie.


UPDATE

Installed Luke, checking out latest index... the Field market_local is available in searches, so if I execute something like:

market_local:Local

The search works correctly (in Luke). I'm going over our Analyzer code now, is there any way I could chalk this issue up to the fact that our search application is using Lucene 2.1.0 and the latest version of Luke is using 2.3.0?

like image 675
Jake McGraw Avatar asked Jun 24 '26 22:06

Jake McGraw


1 Answers

For debugging Lucene, the best tool to use is Luke, which lets you poke around in the index itself to see what got indexed, carry out searches, etc. I recommend downloading it, pointing it at your index, and seeing what's in there.

like image 98
Darren Hague Avatar answered Jun 27 '26 11:06

Darren Hague



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!