I have indexed some records in a JTable , and I am trying to return all records where the value in a particular column starts with a particular value(http://musicbrainz.org:), but I get no matches. If I match for an exact values it works fine, Im stumped as to why this would be the case

//Works ok
DataIndexer.getInstance().singleTermSearch(ID3TagNames.INDEX_UFID,"http://musicbrainz.org:4d08a37a-6e71-401c-ad54-dbe5a8ae919a";);

//No matches (last option is what I really want to do)
DataIndexer.getInstance().singleTermSearch(ID3TagNames.INDEX_UFID,"http://musicbrainz.org:4d08a37a-6e71-401c-ad54-dbe5a8ae919?";); DataIndexer.getInstance().singleTermSearch(ID3TagNames.INDEX_UFID,"http://musicbrainz.org:4d08a37a-6e71-401c-ad54-dbe5a8ae919*";); DataIndexer.getInstance().singleTermSearch(ID3TagNames.INDEX_UFID,"http://musicbrainz.org:*";);


My Index is constructed using a KeywordAnalyser, the following line add a value to the index (there is one document per row)

document.add(new Field((String) tc.getIdentifier(), columnValue, Field.Store.YES, Field.Index.UN_TOKENIZED));

My Search Code is:
public List <Integer> singleTermSearch(Integer columnId,String searchstring)
   {
       List <Integer> matchingRows = new ArrayList<Integer>();
       try
       {
           //make a new index searcher with the in memory (RAM) index.
           IndexSearcher is = new IndexSearcher(directory);

           //Search on column columnId for value searchstring
TermQuery query = new TermQuery(new Term(String.valueOf(columnId),searchstring));

           //run the search
           Hits hits = is.search(query);

           Iterator i = hits.iterator();
           while(i.hasNext())
           {
               Document doc = ((Hit)i.next()).getDocument();
matchingRows.add(new Integer(doc.getField(ROW_NUMBER).stringValue()));
           }
       }
       catch (Exception e)
       {
           e.printStackTrace();
       }
       return matchingRows;
   }

thanks Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to