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 mete <ef...@gmail.com> on 2012/02/16 09:34:39 UTC

prefix query works, term query does not

Hello,
I have a noobie question. I am trying to implement a small poc app.I have
lots of sharded indexes in a folder and i am trying to read them like this:
        MultiReader reader = new MultiReader(list.toArray(new
IndexReader[list.size()]));
        IndexSearcher searcher = new IndexSearcher(reader,
Executors.newFixedThreadPool(6));

then i am getting the query from the command line and executing it like
this:
        QueryParser parser = new QueryParser(Version.LUCENE_35,
"default-field", new StandardAnalyzer(Version.LUCENE_35));
        Query q = parser.parse(query);

i dont have a default-field actually but i could not figure out what else
to put in there.

Anyway leys say i have an IP address in one of the fields, when i query it
like this:
ip=8.8.8.*
ip=8.8.8.8*
i am able to find it but when i query it with the exact value:
ip=8.8.8.8
there are no hits.

I am able to query it successfully on the same index using luke,

Does anyone have a pointer about what is it that i am doing wrong?

Cheers
Mete

Re: prefix query works, term query does not

Posted by Ian Lea <ia...@gmail.com>.
http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_.2BAC8_incorrect_hits.3F

Different analyzers for indexing and searching would be my first guess.


--
Ian.

On Thu, Feb 16, 2012 at 8:34 AM, mete <ef...@gmail.com> wrote:
> Hello,
> I have a noobie question. I am trying to implement a small poc app.I have
> lots of sharded indexes in a folder and i am trying to read them like this:
>        MultiReader reader = new MultiReader(list.toArray(new
> IndexReader[list.size()]));
>        IndexSearcher searcher = new IndexSearcher(reader,
> Executors.newFixedThreadPool(6));
>
> then i am getting the query from the command line and executing it like
> this:
>        QueryParser parser = new QueryParser(Version.LUCENE_35,
> "default-field", new StandardAnalyzer(Version.LUCENE_35));
>        Query q = parser.parse(query);
>
> i dont have a default-field actually but i could not figure out what else
> to put in there.
>
> Anyway leys say i have an IP address in one of the fields, when i query it
> like this:
> ip=8.8.8.*
> ip=8.8.8.8*
> i am able to find it but when i query it with the exact value:
> ip=8.8.8.8
> there are no hits.
>
> I am able to query it successfully on the same index using luke,
>
> Does anyone have a pointer about what is it that i am doing wrong?
>
> Cheers
> Mete

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: prefix query works, term query does not

Posted by "Francisco A. Lozano" <fl...@gmail.com>.
Use luke to see what terms are in your index and what your query looks
like when parsed.

Also, when I want to search the field with all the analysis stuff but
also be able to search by exact keyword, I index it twice, with two
fields with the same name: one of them is analyzed and the other not.
It's hacky and probably incorrect, but it works...

Francisco A. Lozano



On Thu, Feb 16, 2012 at 09:34, mete <ef...@gmail.com> wrote:
> Hello,
> I have a noobie question. I am trying to implement a small poc app.I have
> lots of sharded indexes in a folder and i am trying to read them like this:
>        MultiReader reader = new MultiReader(list.toArray(new
> IndexReader[list.size()]));
>        IndexSearcher searcher = new IndexSearcher(reader,
> Executors.newFixedThreadPool(6));
>
> then i am getting the query from the command line and executing it like
> this:
>        QueryParser parser = new QueryParser(Version.LUCENE_35,
> "default-field", new StandardAnalyzer(Version.LUCENE_35));
>        Query q = parser.parse(query);
>
> i dont have a default-field actually but i could not figure out what else
> to put in there.
>
> Anyway leys say i have an IP address in one of the fields, when i query it
> like this:
> ip=8.8.8.*
> ip=8.8.8.8*
> i am able to find it but when i query it with the exact value:
> ip=8.8.8.8
> there are no hits.
>
> I am able to query it successfully on the same index using luke,
>
> Does anyone have a pointer about what is it that i am doing wrong?
>
> Cheers
> Mete

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org