You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mikal sk�ren <mi...@hotmail.com> on 2007/10/04 20:27:32 UTC
Promblems with searching a field
Hi,
I am new to lucene and am currently having some problems searching an index.
so we make the index like this :
doc.add(new Field("itno", item.getMMITNO(), Field.Store.YES,
Field.Index.TOKENIZED ));
this runs ok the index looks like this :
[stored/uncompressed,indexed,tokenized<itno:00000002 >,
But when we try searching this field we get no hits (search is 00000002,
ItemIndexing.getAnalyzer() == SimpleAnalyzer)
try {
Hits hits =
indexSearcher.search(newQueryParser("itno",ItemIndexing.getAnalyzer()).parse(search));
//Returns 0
log.info("Size " + hits.length());
List result = getResult(hits);
indexSearcher.close();
return result;
} catch (Exception e) {
What are we doing wrong, any help would be appreciated..
_________________________________________________________________
Trangt om plassen? http://www.hotmail.com MSN Hotmail gir deg 250MB gratis
lagringsplass
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Promblems with searching a field
Posted by Erick Erickson <er...@gmail.com>.
It's hard to say, but two things will help you track this down.
1> get a copy of Luke to examine your index (which you may have already).
2> Query.toString is your friend. It'll show you exactly what the parsed
query looks like. It may be obvious when you see that output
what the problem is, but if not you can try moving the parsed
code into the search tab of Luke and glean more info.
Where did you get this data: "<itno:00000002 >,"? It's kind of
interesting that there are spaces AFTER the 000000002. What analyzer
did you use when you indexed it and can you guarantee that it's
the same analyzer that you used to parse the query?
And one aside. Opening and closing a searcher for each request is
very wasteful. Is closing your searcher just an artifact of cutting/pasting?
If not, you haven't opened the searcher in the snippet either <G>...
Best
Erick
On 10/4/07, Mikal skåren <mi...@hotmail.com> wrote:
>
> Hi,
> I am new to lucene and am currently having some problems searching an
> index.
>
> so we make the index like this :
>
> doc.add(new Field("itno", item.getMMITNO(), Field.Store.YES,
> Field.Index.TOKENIZED ));
>
> this runs ok the index looks like this :
>
> [stored/uncompressed,indexed,tokenized<itno:00000002 >,
>
> But when we try searching this field we get no hits (search is 00000002,
> ItemIndexing.getAnalyzer() == SimpleAnalyzer)
>
> try {
> Hits hits =
> indexSearcher.search(newQueryParser("itno",ItemIndexing.getAnalyzer
> ()).parse(search));
> //Returns 0
> log.info("Size " + hits.length());
> List result = getResult(hits);
> indexSearcher.close();
>
> return result;
> } catch (Exception e) {
>
>
> What are we doing wrong, any help would be appreciated..
>
> _________________________________________________________________
> Trangt om plassen? http://www.hotmail.com MSN Hotmail gir deg 250MB gratis
> lagringsplass
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>