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 Tom Emerson <tr...@gmail.com> on 2007/12/07 22:21:54 UTC

Re: Rewrite one phrase to another in search query

Hi Mark,

Thanks for the pointer, but for my application I already have a custom query
parser, and I think the use of a functional query will do what I want.

    -tree

On Jun 28, 2007 7:46 PM, Mark Miller <ma...@gmail.com> wrote:

> You might try my Query Parser, Qsol. http://myhardshadow.com/qsol.php
> There is a find/replace feature that will do what you want. FindReplace
> takes the find string, the replace string, boolean for case sensitive,
> boolean to indicate the replacement will act as an operator (allows for
> correct default space operator functionality).
>
> - Mark
> Example Code:
>
>        QsolParser parser = ParserFactory.getInstance(new
> QsolConfiguration())
>                                     .getParser(false);
>
>        parser.addFindReplace(new FindReplace("\"the old fast razor\"",
> "tofr",
>                true, false));
>
>        parser.addFindReplace(new FindReplace("tofr", "\"the old fast
> razor\"",
>                true, false));
>
>        example = "test(\"the old fast razor\" & mark)";
>        expected = "+test:tofr +test:mark";
>        assertEquals(expected, parse(example));
>
>        Parse Method:
>
>        Query result = null;
>        try {
>            result = parser.parse("field", query, analyzer);
>        } catch (EmptyQueryException e) {
>            return "";
>        } catch (QsolSyntaxException e) {
>            throw new RuntimeException(e);
>        }
>
>        return result.toString();
>
> Aliaksandr Radzivanovich wrote:
> > What if I need to search for synonyms, but synonyms can be expanded to
> > phrases of several words?
> > For example, user enters query "tcp", then my application should also
> > find documents containing phrase "Transmission Control Protocol". And
> > conversely, user enters "Transmission Control Protocol", then my
> > application should also find documents with word "tcp".
> >
> > It seems like Lucene does not support this scenario out of the box.
> > Then where to look for the solution? What Lucene
> > extensions/classes/interfaces should I investigate?
> >
> > Thanks.
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
Tom Emerson
tremerson@gmail.com
http://www.dreamersrealm.net/~tree

Re: Rewrite one phrase to another in search query

Posted by Tom Emerson <tr...@gmail.com>.
Bleh, never mind this, I've replied to the wrong thread... mea culpa.

On Dec 7, 2007 4:21 PM, Tom Emerson <tr...@gmail.com> wrote:

> Hi Mark,
>
> Thanks for the pointer, but for my application I already have a custom
> query parser, and I think the use of a functional query will do what I want.
>
>     -tree
>
>
> On Jun 28, 2007 7:46 PM, Mark Miller < markrmiller@gmail.com> wrote:
>
> > You might try my Query Parser, Qsol. http://myhardshadow.com/qsol.php
> > There is a find/replace feature that will do what you want. FindReplace
> > takes the find string, the replace string, boolean for case sensitive,
> > boolean to indicate the replacement will act as an operator (allows for
> > correct default space operator functionality).
> >
> > - Mark
> > Example Code:
> >
> >        QsolParser parser = ParserFactory.getInstance(new
> > QsolConfiguration())
> >                                     .getParser(false);
> >
> >        parser.addFindReplace(new FindReplace("\"the old fast razor\"",
> > "tofr",
> >                true, false));
> >
> >        parser.addFindReplace(new FindReplace("tofr", "\"the old fast
> > razor\"",
> >                true, false));
> >
> >        example = "test(\"the old fast razor\" & mark)";
> >        expected = "+test:tofr +test:mark";
> >        assertEquals(expected, parse(example));
> >
> >        Parse Method:
> >
> >        Query result = null;
> >        try {
> >            result = parser.parse ("field", query, analyzer);
> >        } catch (EmptyQueryException e) {
> >            return "";
> >        } catch (QsolSyntaxException e) {
> >            throw new RuntimeException(e);
> >        }
> >
> >        return result.toString();
> >
> > Aliaksandr Radzivanovich wrote:
> > > What if I need to search for synonyms, but synonyms can be expanded to
> > > phrases of several words?
> > > For example, user enters query "tcp", then my application should also
> > > find documents containing phrase "Transmission Control Protocol". And
> > > conversely, user enters "Transmission Control Protocol", then my
> > > application should also find documents with word "tcp".
> > >
> > > It seems like Lucene does not support this scenario out of the box.
> > > Then where to look for the solution? What Lucene
> > > extensions/classes/interfaces should I investigate?
> > >
> > > Thanks.
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
> --
> Tom Emerson
> tremerson@gmail.com
> http://www.dreamersrealm.net/~tree <http://www.dreamersrealm.net/%7Etree>
>



-- 
Tom Emerson
tremerson@gmail.com
http://www.dreamersrealm.net/~tree