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 Dirk Reske <di...@studiorga.de> on 2010/11/02 15:14:40 UTC

Simple search question

Hello,

we are quite new to lucene.
At first we want to create a simple user search for our web 
application.
My first thought was to map die 'display name' (= firstname + 
lastname) to a single field (analysed but not stored)
and to put the database id of the user to a stored, not analysed field 
(but indexed).

Then the user should have a simple text box, where he should be able 
to write the whole name, parts of the name etc...
So a search for "jo do" should also return the user "John Doe". How to 
create the query?

My first solution was to tokenize the string using whitespaces an add 
an * to each word and then concatenate all the words and use the query 
parser,
so that the search string would be "jo* do*"...but then I've read, 
that I should not programmaticly construct a string and use the 
queryparser.

So what is the right way?

Greets
Dirk


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


Re: Simple search question

Posted by Ian Lea <ia...@gmail.com>.
Tokenizing and then passing through the query parser sounds reasonable
to me.  You could build the query yourself, but that will be a bit
more work.  You could also combine a non-wildcard search with a
wildcard search, boosting the first one.  So that "John Doe" would
score higher than "Johnny Doncaster".


--
Ian.


On Tue, Nov 2, 2010 at 2:39 PM, Dirk Reske <di...@studiorga.de> wrote:
> No, we don't want to user to write the * itself.
> And seperate fields for the first and the last name are also not
> acceptable.
>
> Image all the social networks, where you type a part of a name into the
> textbox, and get all people whose names (first or last) contains one of
> your searched words. The user should not be thinking about...just doing
> it.
>
> Dirk
>
> On Tue, 2 Nov 2010 20:00:08 +0530, findbestopensource
> <fi...@gmail.com> wrote:
>> Yes. Correct. It would be good, If User inputs the search string with *.
>>
>> My Idea is to index two fields separately first name and last name. Provide
>> two text boxes with first name and last name. Leave the rest to the User.
>>
>> Regrads
>> Aditya
>> www.findbestopensource.com
>>
>>
>>
>> On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:
>>
>>> Hello,
>>>
>>> we are quite new to lucene.
>>> At first we want to create a simple user search for our web application.
>>> My first thought was to map die 'display name' (= firstname + lastname) to
>>> a single field (analysed but not stored)
>>> and to put the database id of the user to a stored, not analysed field (but
>>> indexed).
>>>
>>> Then the user should have a simple text box, where he should be able to
>>> write the whole name, parts of the name etc...
>>> So a search for "jo do" should also return the user "John Doe". How to
>>> create the query?
>>>
>>> My first solution was to tokenize the string using whitespaces an add an *
>>> to each word and then concatenate all the words and use the query parser,
>>> so that the search string would be "jo* do*"...but then I've read, that I
>>> should not programmaticly construct a string and use the queryparser.
>>>
>>> So what is the right way?
>>>
>>> Greets
>>> Dirk
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>>>
>
> --
> Dirk Reske
> Vogelsangstr. 24
> 18437 Stralsund
>
> mail: dirk@studiorga.de
> mobile: +(49) 1522 2104741
>
> ---------------------------------------------------------------------
> 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: Simple search question

Posted by da...@ontrenet.com.
Couldn't one write a custom filter that modified the inbound term
semantics before doing the search? Then, wildcard behavior can be added to
terms without doing query string splicing.

> You might take a look at Ngrams. These can be used to find partial
> matches without resorting to wildcards, although they may add to
> your index size...
>
> Best
> Erick
>
> On Tue, Nov 2, 2010 at 10:39 AM, Dirk Reske <di...@studiorga.de> wrote:
>
>> No, we don't want to user to write the * itself.
>> And seperate fields for the first and the last name are also not
>> acceptable.
>>
>> Image all the social networks, where you type a part of a name into the
>> textbox, and get all people whose names (first or last) contains one of
>> your searched words. The user should not be thinking about...just doing
>> it.
>>
>> Dirk
>>
>> On Tue, 2 Nov 2010 20:00:08 +0530, findbestopensource
>> <fi...@gmail.com> wrote:
>> > Yes. Correct. It would be good, If User inputs the search string with
>> *.
>> >
>> > My Idea is to index two fields separately first name and last name.
>> Provide
>> > two text boxes with first name and last name. Leave the rest to the
>> User.
>> >
>> > Regrads
>> > Aditya
>> > www.findbestopensource.com
>> >
>> >
>> >
>> > On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:
>> >
>> >> Hello,
>> >>
>> >> we are quite new to lucene.
>> >> At first we want to create a simple user search for our web
>> application.
>> >> My first thought was to map die 'display name' (= firstname +
>> lastname)
>> to
>> >> a single field (analysed but not stored)
>> >> and to put the database id of the user to a stored, not analysed
>> field
>> (but
>> >> indexed).
>> >>
>> >> Then the user should have a simple text box, where he should be able
>> to
>> >> write the whole name, parts of the name etc...
>> >> So a search for "jo do" should also return the user "John Doe". How
>> to
>> >> create the query?
>> >>
>> >> My first solution was to tokenize the string using whitespaces an add
>> an
>> *
>> >> to each word and then concatenate all the words and use the query
>> parser,
>> >> so that the search string would be "jo* do*"...but then I've read,
>> that
>> I
>> >> should not programmaticly construct a string and use the queryparser.
>> >>
>> >> So what is the right way?
>> >>
>> >> Greets
>> >> Dirk
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> >> For additional commands, e-mail: java-user-help@lucene.apache.org
>> >>
>> >>
>>
>> --
>> Dirk Reske
>> Vogelsangstr. 24
>> 18437 Stralsund
>>
>> mail: dirk@studiorga.de
>> mobile: +(49) 1522 2104741
>>
>> ---------------------------------------------------------------------
>> 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: Simple search question

Posted by Erick Erickson <er...@gmail.com>.
You might take a look at Ngrams. These can be used to find partial
matches without resorting to wildcards, although they may add to
your index size...

Best
Erick

On Tue, Nov 2, 2010 at 10:39 AM, Dirk Reske <di...@studiorga.de> wrote:

> No, we don't want to user to write the * itself.
> And seperate fields for the first and the last name are also not
> acceptable.
>
> Image all the social networks, where you type a part of a name into the
> textbox, and get all people whose names (first or last) contains one of
> your searched words. The user should not be thinking about...just doing
> it.
>
> Dirk
>
> On Tue, 2 Nov 2010 20:00:08 +0530, findbestopensource
> <fi...@gmail.com> wrote:
> > Yes. Correct. It would be good, If User inputs the search string with *.
> >
> > My Idea is to index two fields separately first name and last name.
> Provide
> > two text boxes with first name and last name. Leave the rest to the User.
> >
> > Regrads
> > Aditya
> > www.findbestopensource.com
> >
> >
> >
> > On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:
> >
> >> Hello,
> >>
> >> we are quite new to lucene.
> >> At first we want to create a simple user search for our web application.
> >> My first thought was to map die 'display name' (= firstname + lastname)
> to
> >> a single field (analysed but not stored)
> >> and to put the database id of the user to a stored, not analysed field
> (but
> >> indexed).
> >>
> >> Then the user should have a simple text box, where he should be able to
> >> write the whole name, parts of the name etc...
> >> So a search for "jo do" should also return the user "John Doe". How to
> >> create the query?
> >>
> >> My first solution was to tokenize the string using whitespaces an add an
> *
> >> to each word and then concatenate all the words and use the query
> parser,
> >> so that the search string would be "jo* do*"...but then I've read, that
> I
> >> should not programmaticly construct a string and use the queryparser.
> >>
> >> So what is the right way?
> >>
> >> Greets
> >> Dirk
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
>
> --
> Dirk Reske
> Vogelsangstr. 24
> 18437 Stralsund
>
> mail: dirk@studiorga.de
> mobile: +(49) 1522 2104741
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Simple search question

Posted by findbestopensource <fi...@gmail.com>.
In this case also, You may need to index the fields separately. This will
give better control. Have a parser, which splits the terms and applies * to
the end. Search using the terms.

Regards
Aditya
www.findbestopensource.com


On Tue, Nov 2, 2010 at 8:09 PM, Dirk Reske <di...@studiorga.de> wrote:

> No, we don't want to user to write the * itself.
> And seperate fields for the first and the last name are also not
> acceptable.
>
> Image all the social networks, where you type a part of a name into the
> textbox, and get all people whose names (first or last) contains one of
> your searched words. The user should not be thinking about...just doing
> it.
>
> Dirk
>
> On Tue, 2 Nov 2010 20:00:08 +0530, findbestopensource
> <fi...@gmail.com> wrote:
> > Yes. Correct. It would be good, If User inputs the search string with *.
> >
> > My Idea is to index two fields separately first name and last name.
> Provide
> > two text boxes with first name and last name. Leave the rest to the User.
> >
> > Regrads
> > Aditya
> > www.findbestopensource.com
> >
> >
> >
> > On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:
> >
> >> Hello,
> >>
> >> we are quite new to lucene.
> >> At first we want to create a simple user search for our web application.
> >> My first thought was to map die 'display name' (= firstname + lastname)
> to
> >> a single field (analysed but not stored)
> >> and to put the database id of the user to a stored, not analysed field
> (but
> >> indexed).
> >>
> >> Then the user should have a simple text box, where he should be able to
> >> write the whole name, parts of the name etc...
> >> So a search for "jo do" should also return the user "John Doe". How to
> >> create the query?
> >>
> >> My first solution was to tokenize the string using whitespaces an add an
> *
> >> to each word and then concatenate all the words and use the query
> parser,
> >> so that the search string would be "jo* do*"...but then I've read, that
> I
> >> should not programmaticly construct a string and use the queryparser.
> >>
> >> So what is the right way?
> >>
> >> Greets
> >> Dirk
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
>
> --
> Dirk Reske
> Vogelsangstr. 24
> 18437 Stralsund
>
> mail: dirk@studiorga.de
> mobile: +(49) 1522 2104741
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Simple search question

Posted by Dirk Reske <di...@studiorga.de>.
No, we don't want to user to write the * itself.
And seperate fields for the first and the last name are also not
acceptable.

Image all the social networks, where you type a part of a name into the
textbox, and get all people whose names (first or last) contains one of
your searched words. The user should not be thinking about...just doing
it.

Dirk

On Tue, 2 Nov 2010 20:00:08 +0530, findbestopensource
<fi...@gmail.com> wrote:
> Yes. Correct. It would be good, If User inputs the search string with *.
> 
> My Idea is to index two fields separately first name and last name. Provide
> two text boxes with first name and last name. Leave the rest to the User.
> 
> Regrads
> Aditya
> www.findbestopensource.com
> 
> 
> 
> On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:
> 
>> Hello,
>>
>> we are quite new to lucene.
>> At first we want to create a simple user search for our web application.
>> My first thought was to map die 'display name' (= firstname + lastname) to
>> a single field (analysed but not stored)
>> and to put the database id of the user to a stored, not analysed field (but
>> indexed).
>>
>> Then the user should have a simple text box, where he should be able to
>> write the whole name, parts of the name etc...
>> So a search for "jo do" should also return the user "John Doe". How to
>> create the query?
>>
>> My first solution was to tokenize the string using whitespaces an add an *
>> to each word and then concatenate all the words and use the query parser,
>> so that the search string would be "jo* do*"...but then I've read, that I
>> should not programmaticly construct a string and use the queryparser.
>>
>> So what is the right way?
>>
>> Greets
>> Dirk
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>

-- 
Dirk Reske
Vogelsangstr. 24
18437 Stralsund

mail: dirk@studiorga.de
mobile: +(49) 1522 2104741

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


Re: Simple search question

Posted by findbestopensource <fi...@gmail.com>.
Yes. Correct. It would be good, If User inputs the search string with *.

My Idea is to index two fields separately first name and last name. Provide
two text boxes with first name and last name. Leave the rest to the User.

Regrads
Aditya
www.findbestopensource.com



On Tue, Nov 2, 2010 at 7:44 PM, Dirk Reske <di...@studiorga.de> wrote:

> Hello,
>
> we are quite new to lucene.
> At first we want to create a simple user search for our web application.
> My first thought was to map die 'display name' (= firstname + lastname) to
> a single field (analysed but not stored)
> and to put the database id of the user to a stored, not analysed field (but
> indexed).
>
> Then the user should have a simple text box, where he should be able to
> write the whole name, parts of the name etc...
> So a search for "jo do" should also return the user "John Doe". How to
> create the query?
>
> My first solution was to tokenize the string using whitespaces an add an *
> to each word and then concatenate all the words and use the query parser,
> so that the search string would be "jo* do*"...but then I've read, that I
> should not programmaticly construct a string and use the queryparser.
>
> So what is the right way?
>
> Greets
> Dirk
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>