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 Damerian <da...@gmail.com> on 2012/03/01 14:12:30 UTC
Re: QueryParser strange behavior
Hello again!
First of all thank you again for replying my amateur questions.
I would like to rephrase my question because now what i described is not
the case and its not a problem of input methods.
I have made my custom analyzer which when indexing e.g the phrase "The
quick Brown Fox"
will produce the following tokens
[The]
[quick]
[Brown Fox]
when i use exactly the same analyser to construct a search query i get
the following result:
"With ProperNameAnalyzerThe quick Brown Fox parses to The quick Brown
Fox query: contents:The contents:quick contents:Brown contents:Fox"
which means that the analyzer fails to combine Brown and Fox into one
token and make it a single term for the search as expected.
Any insights on this?
Once again thank you for your time and patience.
Στις 28/2/2012 11:51 πμ, ο/η Ian Lea έγραψε:
> Then I don't know. Something trivial like white space? What does
> line.equals("Jesus Christ") say?
>
>
> --
> Ian.
>
>
> On Mon, Feb 27, 2012 at 7:42 PM, Damerian<da...@gmail.com> wrote:
>> Στις 27/2/2012 11:45 πμ, ο/η Ian Lea έγραψε:
>>> Does your analyzer look for a field called content, not contents?
>>>
>>>
>>> --
>>> Ian.
>>>
>>>
>>> On Sat, Feb 25, 2012 at 6:37 AM, Damerian<da...@gmail.com> wrote:
>>>> Hello!
>>>>
>>>> I have a small issue with the QueryParser in my program.
>>>> It uses my custom filter to Parse its queries, but i get unexpexted
>>>> results
>>>> from when i am having an input from the keyboard
>>>> To illustrate
>>>> the code :
>>>> Analyzer myAnalyzer = new ProperNameAnalyzer();
>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>> "content",
>>>> myAnalyzer).parse("Jesus Christ");
>>>> //assertEquals(1, TestUtil.hitCount(searcher, query));
>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to "
>>>> +
>>>> query.toString("content")+ "
>>>> query:
>>>> " +query);
>>>>
>>>>
>>>> will produce the following (expected ) output:
>>>> With ProperNameAnalyzer, "Jesus Christ" parses to "Jesus Christ" query:
>>>> contents:"Jesus Christ"
>>>>
>>>> Although with a small addition of keyboard iinteraction:
>>>> BufferedReader in = null;
>>>> String line = in.readLine();
>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>> "contents",
>>>> analyzer).parse(line);
>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to " +
>>>> query.toString("contents")+ "
>>>> query:
>>>> " +query);
>>>>
>>>> Will produce the incorrect and unexpected output:
>>>> With ProperNameAnalyzer, "Jesus Christ" parses to Jesus Christ query:
>>>> contents:Jesus contents:Christ
>>>>
>>>>
>>>> Any ideas why this may happen?
>>>> Thanks in advance!
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>> Thanks for the reply!
>> No that's not the case... It was a typographic mistake here cause i took the
>> code from my demo program (the one i use to test the code) i have the same
>> name for the fields in both cases (hard coded and use input)
>> regards!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: QueryParser strange behavior
Posted by Ganesh <em...@yahoo.co.in>.
It is fixed now. I need to enable
qp.setAutoGeneratePhraseQueries(true);
Regards
Ganesh
----- Original Message -----
From: "Ganesh" <em...@yahoo.co.in>
To: <ja...@lucene.apache.org>
Sent: Friday, March 02, 2012 10:46 AM
Subject: Re: QueryParser strange behavior
Hello Damerian,
Please let me know, How you fixed the problem? I am facing similar kind of issue.
My analyzer produces multiple tokens. When i search usig 3.0.3, the query expands to +field: "token1 token2" but now in 3.5, +field(token1 token2). It is doing OR search now. If either of the token matches, it returns the results.
Regards
Ganesh
----- Original Message -----
From: "Damerian" <da...@gmail.com>
To: <ja...@lucene.apache.org>
Sent: Thursday, March 01, 2012 7:57 PM
Subject: Re: QueryParser strange behavior
> Στις 1/3/2012 3:08 μμ, ο/η Ian Lea έγραψε:
>> Not a clue. I suggest you post a small, complete and self-contained
>> (no external dependencies) program or test case that demonstrates the
>> problem. And your analyzer.
>>
>>
>> --
>> Ian.
>>
>>
>> 2012/3/1 Damerian<da...@gmail.com>:
>>> Hello again!
>>> First of all thank you again for replying my amateur questions.
>>> I would like to rephrase my question because now what i described is not the
>>> case and its not a problem of input methods.
>>>
>>> I have made my custom analyzer which when indexing e.g the phrase "The quick
>>> Brown Fox"
>>> will produce the following tokens
>>> [The]
>>> [quick]
>>> [Brown Fox]
>>>
>>> when i use exactly the same analyser to construct a search query i get the
>>> following result:
>>> "With ProperNameAnalyzerThe quick Brown Fox parses to The quick Brown Fox
>>> query: contents:The contents:quick contents:Brown contents:Fox"
>>> which means that the analyzer fails to combine Brown and Fox into one token
>>> and make it a single term for the search as expected.
>>> Any insights on this?
>>> Once again thank you for your time and patience.
>>>
>>> Στις 28/2/2012 11:51 πμ, ο/η Ian Lea έγραψε:
>>>> Then I don't know. Something trivial like white space? What does
>>>> line.equals("Jesus Christ") say?
>>>>
>>>>
>>>> --
>>>> Ian.
>>>>
>>>>
>>>> On Mon, Feb 27, 2012 at 7:42 PM, Damerian<da...@gmail.com> wrote:
>>>>> Στις 27/2/2012 11:45 πμ, ο/η Ian Lea έγραψε:
>>>>>> Does your analyzer look for a field called content, not contents?
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Ian.
>>>>>>
>>>>>>
>>>>>> On Sat, Feb 25, 2012 at 6:37 AM, Damerian<da...@gmail.com>
>>>>>> wrote:
>>>>>>> Hello!
>>>>>>>
>>>>>>> I have a small issue with the QueryParser in my program.
>>>>>>> It uses my custom filter to Parse its queries, but i get unexpexted
>>>>>>> results
>>>>>>> from when i am having an input from the keyboard
>>>>>>> To illustrate
>>>>>>> the code :
>>>>>>> Analyzer myAnalyzer = new ProperNameAnalyzer();
>>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>>> "content",
>>>>>>> myAnalyzer).parse("Jesus Christ");
>>>>>>> //assertEquals(1, TestUtil.hitCount(searcher, query));
>>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to
>>>>>>> "
>>>>>>> +
>>>>>>> query.toString("content")+ "
>>>>>>> query:
>>>>>>> " +query);
>>>>>>>
>>>>>>>
>>>>>>> will produce the following (expected ) output:
>>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to "Jesus Christ" query:
>>>>>>> contents:"Jesus Christ"
>>>>>>>
>>>>>>> Although with a small addition of keyboard iinteraction:
>>>>>>> BufferedReader in = null;
>>>>>>> String line = in.readLine();
>>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>>> "contents",
>>>>>>> analyzer).parse(line);
>>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to "
>>>>>>> +
>>>>>>> query.toString("contents")+ "
>>>>>>> query:
>>>>>>> " +query);
>>>>>>>
>>>>>>> Will produce the incorrect and unexpected output:
>>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to Jesus Christ query:
>>>>>>> contents:Jesus contents:Christ
>>>>>>>
>>>>>>>
>>>>>>> Any ideas why this may happen?
>>>>>>> Thanks in advance!
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>>
>>>>> Thanks for the reply!
>>>>> No that's not the case... It was a typographic mistake here cause i took
>>>>> the
>>>>> code from my demo program (the one i use to test the code) i have the
>>>>> same
>>>>> name for the fields in both cases (hard coded and use input)
>>>>> regards!
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
> Hi!
> Thanks for the immediate reply, i just fixed it though!
> apparently the QueryParser consructs a query regardless of the
> analyzer's tokens
> I simply created my own booleanQuery by calling my custom analyzer and
> treating the user inputed query text as a stream.
> The result works perfectly!
> Thank you again for your time and patience! :-)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: QueryParser strange behavior
Posted by Ganesh <em...@yahoo.co.in>.
Hello Damerian,
Please let me know, How you fixed the problem? I am facing similar kind of issue.
My analyzer produces multiple tokens. When i search usig 3.0.3, the query expands to +field: "token1 token2" but now in 3.5, +field(token1 token2). It is doing OR search now. If either of the token matches, it returns the results.
Regards
Ganesh
----- Original Message -----
From: "Damerian" <da...@gmail.com>
To: <ja...@lucene.apache.org>
Sent: Thursday, March 01, 2012 7:57 PM
Subject: Re: QueryParser strange behavior
> Στις 1/3/2012 3:08 μμ, ο/η Ian Lea έγραψε:
>> Not a clue. I suggest you post a small, complete and self-contained
>> (no external dependencies) program or test case that demonstrates the
>> problem. And your analyzer.
>>
>>
>> --
>> Ian.
>>
>>
>> 2012/3/1 Damerian<da...@gmail.com>:
>>> Hello again!
>>> First of all thank you again for replying my amateur questions.
>>> I would like to rephrase my question because now what i described is not the
>>> case and its not a problem of input methods.
>>>
>>> I have made my custom analyzer which when indexing e.g the phrase "The quick
>>> Brown Fox"
>>> will produce the following tokens
>>> [The]
>>> [quick]
>>> [Brown Fox]
>>>
>>> when i use exactly the same analyser to construct a search query i get the
>>> following result:
>>> "With ProperNameAnalyzerThe quick Brown Fox parses to The quick Brown Fox
>>> query: contents:The contents:quick contents:Brown contents:Fox"
>>> which means that the analyzer fails to combine Brown and Fox into one token
>>> and make it a single term for the search as expected.
>>> Any insights on this?
>>> Once again thank you for your time and patience.
>>>
>>> Στις 28/2/2012 11:51 πμ, ο/η Ian Lea έγραψε:
>>>> Then I don't know. Something trivial like white space? What does
>>>> line.equals("Jesus Christ") say?
>>>>
>>>>
>>>> --
>>>> Ian.
>>>>
>>>>
>>>> On Mon, Feb 27, 2012 at 7:42 PM, Damerian<da...@gmail.com> wrote:
>>>>> Στις 27/2/2012 11:45 πμ, ο/η Ian Lea έγραψε:
>>>>>> Does your analyzer look for a field called content, not contents?
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Ian.
>>>>>>
>>>>>>
>>>>>> On Sat, Feb 25, 2012 at 6:37 AM, Damerian<da...@gmail.com>
>>>>>> wrote:
>>>>>>> Hello!
>>>>>>>
>>>>>>> I have a small issue with the QueryParser in my program.
>>>>>>> It uses my custom filter to Parse its queries, but i get unexpexted
>>>>>>> results
>>>>>>> from when i am having an input from the keyboard
>>>>>>> To illustrate
>>>>>>> the code :
>>>>>>> Analyzer myAnalyzer = new ProperNameAnalyzer();
>>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>>> "content",
>>>>>>> myAnalyzer).parse("Jesus Christ");
>>>>>>> //assertEquals(1, TestUtil.hitCount(searcher, query));
>>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to
>>>>>>> "
>>>>>>> +
>>>>>>> query.toString("content")+ "
>>>>>>> query:
>>>>>>> " +query);
>>>>>>>
>>>>>>>
>>>>>>> will produce the following (expected ) output:
>>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to "Jesus Christ" query:
>>>>>>> contents:"Jesus Christ"
>>>>>>>
>>>>>>> Although with a small addition of keyboard iinteraction:
>>>>>>> BufferedReader in = null;
>>>>>>> String line = in.readLine();
>>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>>> "contents",
>>>>>>> analyzer).parse(line);
>>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to "
>>>>>>> +
>>>>>>> query.toString("contents")+ "
>>>>>>> query:
>>>>>>> " +query);
>>>>>>>
>>>>>>> Will produce the incorrect and unexpected output:
>>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to Jesus Christ query:
>>>>>>> contents:Jesus contents:Christ
>>>>>>>
>>>>>>>
>>>>>>> Any ideas why this may happen?
>>>>>>> Thanks in advance!
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>>
>>>>> Thanks for the reply!
>>>>> No that's not the case... It was a typographic mistake here cause i took
>>>>> the
>>>>> code from my demo program (the one i use to test the code) i have the
>>>>> same
>>>>> name for the fields in both cases (hard coded and use input)
>>>>> regards!
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
> Hi!
> Thanks for the immediate reply, i just fixed it though!
> apparently the QueryParser consructs a query regardless of the
> analyzer's tokens
> I simply created my own booleanQuery by calling my custom analyzer and
> treating the user inputed query text as a stream.
> The result works perfectly!
> Thank you again for your time and patience! :-)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: QueryParser strange behavior
Posted by Damerian <da...@gmail.com>.
Στις 1/3/2012 3:08 μμ, ο/η Ian Lea έγραψε:
> Not a clue. I suggest you post a small, complete and self-contained
> (no external dependencies) program or test case that demonstrates the
> problem. And your analyzer.
>
>
> --
> Ian.
>
>
> 2012/3/1 Damerian<da...@gmail.com>:
>> Hello again!
>> First of all thank you again for replying my amateur questions.
>> I would like to rephrase my question because now what i described is not the
>> case and its not a problem of input methods.
>>
>> I have made my custom analyzer which when indexing e.g the phrase "The quick
>> Brown Fox"
>> will produce the following tokens
>> [The]
>> [quick]
>> [Brown Fox]
>>
>> when i use exactly the same analyser to construct a search query i get the
>> following result:
>> "With ProperNameAnalyzerThe quick Brown Fox parses to The quick Brown Fox
>> query: contents:The contents:quick contents:Brown contents:Fox"
>> which means that the analyzer fails to combine Brown and Fox into one token
>> and make it a single term for the search as expected.
>> Any insights on this?
>> Once again thank you for your time and patience.
>>
>> Στις 28/2/2012 11:51 πμ, ο/η Ian Lea έγραψε:
>>> Then I don't know. Something trivial like white space? What does
>>> line.equals("Jesus Christ") say?
>>>
>>>
>>> --
>>> Ian.
>>>
>>>
>>> On Mon, Feb 27, 2012 at 7:42 PM, Damerian<da...@gmail.com> wrote:
>>>> Στις 27/2/2012 11:45 πμ, ο/η Ian Lea έγραψε:
>>>>> Does your analyzer look for a field called content, not contents?
>>>>>
>>>>>
>>>>> --
>>>>> Ian.
>>>>>
>>>>>
>>>>> On Sat, Feb 25, 2012 at 6:37 AM, Damerian<da...@gmail.com>
>>>>> wrote:
>>>>>> Hello!
>>>>>>
>>>>>> I have a small issue with the QueryParser in my program.
>>>>>> It uses my custom filter to Parse its queries, but i get unexpexted
>>>>>> results
>>>>>> from when i am having an input from the keyboard
>>>>>> To illustrate
>>>>>> the code :
>>>>>> Analyzer myAnalyzer = new ProperNameAnalyzer();
>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>> "content",
>>>>>> myAnalyzer).parse("Jesus Christ");
>>>>>> //assertEquals(1, TestUtil.hitCount(searcher, query));
>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to
>>>>>> "
>>>>>> +
>>>>>> query.toString("content")+ "
>>>>>> query:
>>>>>> " +query);
>>>>>>
>>>>>>
>>>>>> will produce the following (expected ) output:
>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to "Jesus Christ" query:
>>>>>> contents:"Jesus Christ"
>>>>>>
>>>>>> Although with a small addition of keyboard iinteraction:
>>>>>> BufferedReader in = null;
>>>>>> String line = in.readLine();
>>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>>> "contents",
>>>>>> analyzer).parse(line);
>>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to "
>>>>>> +
>>>>>> query.toString("contents")+ "
>>>>>> query:
>>>>>> " +query);
>>>>>>
>>>>>> Will produce the incorrect and unexpected output:
>>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to Jesus Christ query:
>>>>>> contents:Jesus contents:Christ
>>>>>>
>>>>>>
>>>>>> Any ideas why this may happen?
>>>>>> Thanks in advance!
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>
>>>> Thanks for the reply!
>>>> No that's not the case... It was a typographic mistake here cause i took
>>>> the
>>>> code from my demo program (the one i use to test the code) i have the
>>>> same
>>>> name for the fields in both cases (hard coded and use input)
>>>> regards!
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
Hi!
Thanks for the immediate reply, i just fixed it though!
apparently the QueryParser consructs a query regardless of the
analyzer's tokens
I simply created my own booleanQuery by calling my custom analyzer and
treating the user inputed query text as a stream.
The result works perfectly!
Thank you again for your time and patience! :-)
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: QueryParser strange behavior
Posted by Ian Lea <ia...@gmail.com>.
Not a clue. I suggest you post a small, complete and self-contained
(no external dependencies) program or test case that demonstrates the
problem. And your analyzer.
--
Ian.
2012/3/1 Damerian <da...@gmail.com>:
> Hello again!
> First of all thank you again for replying my amateur questions.
> I would like to rephrase my question because now what i described is not the
> case and its not a problem of input methods.
>
> I have made my custom analyzer which when indexing e.g the phrase "The quick
> Brown Fox"
> will produce the following tokens
> [The]
> [quick]
> [Brown Fox]
>
> when i use exactly the same analyser to construct a search query i get the
> following result:
> "With ProperNameAnalyzerThe quick Brown Fox parses to The quick Brown Fox
> query: contents:The contents:quick contents:Brown contents:Fox"
> which means that the analyzer fails to combine Brown and Fox into one token
> and make it a single term for the search as expected.
> Any insights on this?
> Once again thank you for your time and patience.
>
> Στις 28/2/2012 11:51 πμ, ο/η Ian Lea έγραψε:
>>
>> Then I don't know. Something trivial like white space? What does
>> line.equals("Jesus Christ") say?
>>
>>
>> --
>> Ian.
>>
>>
>> On Mon, Feb 27, 2012 at 7:42 PM, Damerian<da...@gmail.com> wrote:
>>>
>>> Στις 27/2/2012 11:45 πμ, ο/η Ian Lea έγραψε:
>>>>
>>>> Does your analyzer look for a field called content, not contents?
>>>>
>>>>
>>>> --
>>>> Ian.
>>>>
>>>>
>>>> On Sat, Feb 25, 2012 at 6:37 AM, Damerian<da...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hello!
>>>>>
>>>>> I have a small issue with the QueryParser in my program.
>>>>> It uses my custom filter to Parse its queries, but i get unexpexted
>>>>> results
>>>>> from when i am having an input from the keyboard
>>>>> To illustrate
>>>>> the code :
>>>>> Analyzer myAnalyzer = new ProperNameAnalyzer();
>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>> "content",
>>>>> myAnalyzer).parse("Jesus Christ");
>>>>> //assertEquals(1, TestUtil.hitCount(searcher, query));
>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to
>>>>> "
>>>>> +
>>>>> query.toString("content")+ "
>>>>> query:
>>>>> " +query);
>>>>>
>>>>>
>>>>> will produce the following (expected ) output:
>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to "Jesus Christ" query:
>>>>> contents:"Jesus Christ"
>>>>>
>>>>> Although with a small addition of keyboard iinteraction:
>>>>> BufferedReader in = null;
>>>>> String line = in.readLine();
>>>>> Query query = new QueryParser(Version.LUCENE_CURRENT,
>>>>> "contents",
>>>>> analyzer).parse(line);
>>>>> System.out.println("With ProperNameAnalyzer, Jesus Christ parses to "
>>>>> +
>>>>> query.toString("contents")+ "
>>>>> query:
>>>>> " +query);
>>>>>
>>>>> Will produce the incorrect and unexpected output:
>>>>> With ProperNameAnalyzer, "Jesus Christ" parses to Jesus Christ query:
>>>>> contents:Jesus contents:Christ
>>>>>
>>>>>
>>>>> Any ideas why this may happen?
>>>>> Thanks in advance!
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>>
>>> Thanks for the reply!
>>> No that's not the case... It was a typographic mistake here cause i took
>>> the
>>> code from my demo program (the one i use to test the code) i have the
>>> same
>>> name for the fields in both cases (hard coded and use input)
>>> regards!
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org