Mikhail,

Thanks for running those tests.
I haven’t looked into the test, but can you confirm it uses an analyzer with 
the lowercase filter?
Also can you confirm whether the actual query being used contains upper or 
lower case J and S (in you John Smith case)

Apologizes on the 'content:foo'.
I changed the code snippet to "somefield", and missed changing that part of the 
output

David Shifflett


On 10/22/19, 5:51 AM, "Mikhail Khludnev" <m...@apache.org> wrote:

    Hello,
    I wonder how it come up with this particular field :
    content:foo
    Anyway I added some uppercase in the test and it passed despite of it
    
    diff --git
    
a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
    
b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
    index 5935da9..9baa492 100644
    ---
    
a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
    +++
    
b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
    @@ -55,8 +55,8 @@
       boolean inOrder = true;
    
       public void testComplexPhrases() throws Exception {
    -    checkMatches("\"john smith\"", "1"); // Simple multi-term still works
    -    checkMatches("\"j*   smyth~\"", "1,2"); // wildcards and fuzzies are
    OK in
    +    checkMatches("\"John Smith\"", "1"); // Simple multi-term still works
    +    checkMatches("\"J*   Smyth~\"", "1,2"); // wildcards and fuzzies are
    OK in
         // phrases
         checkMatches("\"(jo* -john)  smith\"", "2"); // boolean logic works
         checkMatches("\"jo*  smith\"~2", "1,2,3"); // position logic works.
    @@ -161,11 +161,11 @@
         checkMatches("name:\"j*   smyth~\"", "1,2");
         checkMatches("role:\"developer\"", "1,2");
         checkMatches("role:\"p* manager\"", "4");
    -    checkMatches("role:de*", "1,2,3");
    +    checkMatches("role:De*", "1,2,3");
         checkMatches("name:\"j* smyth~\"~5", "1,2,3");
         checkMatches("role:\"p* manager\" AND name:jack*", "4");
         checkMatches("+role:developer +name:jack*", "");
    -    checkMatches("name:\"john smith\"~2 AND role:designer AND id:3", "3");
    +    checkMatches("name:\"john smith\"~2 AND role:Designer AND id:3", "3");
       }
    
       public void testToStringContainsSlop() throws Exception {
    
    Problem seems a way odd (assuming CPQP does analysis), it seems like
    debugging is the last resort in this particular case.
    
    On Mon, Oct 21, 2019 at 8:31 PM Shifflett, David [USA] <
    shifflett_da...@bah.com> wrote:
    
    > Hi all,
    > Using the code snippet:
    >     ComplexPhraseQueryParser qp = new
    > ComplexPhraseQueryParser(“somefield”, new StandardAnalyzer());
    >     String teststr = "\"Foo Bar\"~2";
    >     Query queryToSearch = qp.parse(teststr);
    >     System.out.println("Query : " + queryToSearch.toString());
    >     System.out.println("Type of query : " +
    > queryToSearch.getClass().getSimpleName());
    >
    > I am getting the output
    >     Query : "Foo Bar"~2
    >     Type of query : ComplexPhraseQuery
    >
    > If I change teststr to "\"Foo Bar\""
    > I get
    >     Query : "Foo Bar"
    >     Type of query : ComplexPhraseQuery
    >
    > If I change teststr to "Foo Bar"
    > I get
    >     Query : content:foo content:bar
    >     Type of query : BooleanQuery
    >
    >
    > In the first two cases I was expecting the search terms to be switched to
    > lowercase.
    >
    > Were the Foo and Bar left as originally specified because the terms are
    > inside double quotes?
    >
    > How can I specify a search term that I want treated as a Phrase,
    > but also have the query parser apply the LowerCaseFilter?
    >
    > I am hoping to avoid the need to handle this using PhraseQuery,
    > and continue to use the QueryParser.
    >
    >
    > Thanks in advance for any help you can give me,
    > David Shifflett
    >
    >
    
    -- 
    Sincerely yours
    Mikhail Khludnev
    


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

Reply via email to