<p>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:</p>

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

<p>Running a query ( * ) against the index will return the following results:</p>

<pre><code>Result 1:
    title: Foo Bar
    market_local: Local

Result 2:
    title: Bar Foo
    market_local: National
</code></pre>

<p>Running a targeted query:</p>

<pre><code>+( market_local:Local )
</code></pre>

<p>won't find any results.</p>

<p>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.</p>

<hr>

<p><strong>UPDATE</strong></p>

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

<pre><code>market_local:Local
</code></pre>

<p>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?</p>

[{'answer_id': 42734, 'author': 'Darren Hague', 'author_id': 4450, 'author_profile': 'https://Stackoverflow.com/users/4450', 'pm_score': 4, 'selected': True, 'text': '<p>For debugging Lucene, the best tool to use is <a href="http://www.getopt.org/luke/" rel="noreferrer">Luke</a>, 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.</p>\n'}, {'answer_id': 43530, 'author': 'Martin McNulty', 'author_id': 4507, 'author_profile': 'https://Stackoverflow.com/users/4507', 'pm_score': 2, 'selected': False, 'text': '<p>The <a href="http://wiki.apache.org/lucene-java/LuceneFAQ#head-3558e5121806fb4fce80fc022d889484a9248b71" rel="nofollow noreferrer">section on "Why am I getting no hits?"</a> in the Lucene FAQ has some suggestions you might find useful.  You\'re using Field.Index.UN_TOKENIZED, so no Analyzer will be used for indexing (I think).  If you\'re using an Analyzer when you\'re searching then that might be the root of your problem - the indexing and searching Analyzers should be the same to make sure you get the right hits.</p>\n'}, {'answer_id': 43546, 'author': 'John', 'author_id': 2168, 'author_profile': 'https://Stackoverflow.com/users/2168', 'pm_score': 1, 'selected': False, 'text': '<p>Another simple thing to do would be to use a debugger or logging statement to check the value of </p>\n\n<blockquote>\n  <p>StringUtils.objectToString(currClip.get("market_local"))</p>\n</blockquote>\n\n<p>to make sure it is what you think it is.</p>\n'}, {'answer_id': 150939, 'author': 'Kai Chan', 'author_id': 23589, 'author_profile': 'https://Stackoverflow.com/users/23589', 'pm_score': 1, 'selected': False, 'text': '<p>Luke is bundled with Lucene, but you can tell Luke to use another version of Lucene. Say "lucene-core-2.1.0.jar" contains Lucene 2.1.0 that you want to use and "luke.jar" contains Luke with Lucene 2.3.0. Then you can start Luke with the following command.</p>\n\n<blockquote>\n  <p>java -classpath lucene-core-2.1.0.jar;luke.jar org.getopt.luke.Luke</p>\n</blockquote>\n\n<p>(The trick is to put your version of Lucene before Luke on the classpath. Also, This is on Windows. On Unix, replace ";" with ":".)</p>\n\n<p>As you can check in Luke,</p>\n\n<blockquote>\n  <p>+( market_local:Local )</p>\n</blockquote>\n\n<p>gets rewritten to</p>\n\n<blockquote>\n  <p>market_local:Local</p>\n</blockquote>\n\n<p>if <a href="http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/search/Query.html#rewrite(org.apache.lucene.index.IndexReader)" rel="nofollow noreferrer">the rewrite(IndexReader) method of the Query object</a> is called. The two queries should be equivalent so there might be a bug in 2.1. If you have to use 2.1, you can try to manually call that method before passing the Query object to the IndexSearcher.</p>\n'}]
['https://Stackoverflow.com/questions/42575', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/302/']