Java – Troubleshoot Java Lucene ignoring Field

javalucene

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?

Best Answer

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.