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 "Michael J. Prichard" <mi...@mac.com> on 2007/03/23 20:39:22 UTC

Search Design Question

Hello All,

We allow our users to search through our index with a simple textfield.  
The search phrase has "content" as its default value.  This allows them 
to search quickly through content but then when they type "to:blah AND 
from:foo AND content:boogie" it will know to parse,etc.

What I want to do it expand it so when they type a phrase in the 
textfield it will search select all at once and still be smart enough to 
recognize a lucene query.

For example,  say we have these fields:

to
from
content
subject

When I type "michael contract negotiation" it will look through all 
these fields and return hits.

Then it should be able to recognize more advance searches like:

to:michael AND content:foo

and not go through all fields....

Am I making sense?  Is this a good way to provide search?  How would I 
do this?

Thanks,
Michael


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


Re: Search Design Question

Posted by Chris Hostetter <ho...@fucit.org>.
: One final note, it may be much easier for you to throw all the
: fields into a single uber-field and search that rather than implement
: all four separate clauses, but it's a trade off between simplicity and
: size.....

this would be a very simple way to get the behavior you describe straight
from the lucene QueryParser ... i would certinaly recommend that approach.




-Hoss


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


Re: Search Design Question

Posted by Erick Erickson <er...@gmail.com>.
I don't believe there's anything built into Lucene that helps you out here
because you're really saying "do special things for my problem space
in these situations".

So about the only thing you can do that I know of is to construct the
query yourself by making a series of additions to BooleanQuery
based on your particular problem space.

Which you have to do anyway because you want to turn a simple
michael query into
to:michael from:micheal contents:michael subject:michael
(note default or)....

So you'll have to do something like
if (term has colon) {
    just add boolean clause for that term in that field
} else {
   add all four clauses
}

However, be warned...... this is not a trivial task if you want to
support arbitrary grouping, implement precedence, etc. Search
the list for "bad query bug" for an explanation, or go to the FAQ and
look at something like "why don't I get what I expect from queries".
In fact, you really need to look at and understand that FAQ entry
before you let Lucene loose on queries with AND, OR and NOT
in them. It'll be well worth your time......

One final note, it may be much easier for you to throw all the
fields into a single uber-field and search that rather than implement
all four separate clauses, but it's a trade off between simplicity and
size.....

Best
Erick

On 3/23/07, Michael J. Prichard <mi...@mac.com> wrote:
>
> Hello All,
>
> We allow our users to search through our index with a simple textfield.
> The search phrase has "content" as its default value.  This allows them
> to search quickly through content but then when they type "to:blah AND
> from:foo AND content:boogie" it will know to parse,etc.
>
> What I want to do it expand it so when they type a phrase in the
> textfield it will search select all at once and still be smart enough to
> recognize a lucene query.
>
> For example,  say we have these fields:
>
> to
> from
> content
> subject
>
> When I type "michael contract negotiation" it will look through all
> these fields and return hits.
>
> Then it should be able to recognize more advance searches like:
>
> to:michael AND content:foo
>
> and not go through all fields....
>
> Am I making sense?  Is this a good way to provide search?  How would I
> do this?
>
> Thanks,
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Search Design Question

Posted by Xiaocheng Luan <je...@yahoo.com>.
Hi Michael, 

if I understand your questions correctly - feels like I must have missed something - here is what can do to achieve what you want:

index these fields:

to
from
content
subject
all (includes text from all the above 4 fields)

and use "all" as your default search field. Then when you type "michael contract negotiation", you'll be searching "all" field, which is "all the fields". When you type "to:michael AND content:foo", you will be searching the specified fields only.

Thanks,
Xiaocheng



"Michael J. Prichard" <mi...@mac.com> wrote: Hello All,

We allow our users to search through our index with a simple textfield.  
The search phrase has "content" as its default value.  This allows them 
to search quickly through content but then when they type "to:blah AND 
from:foo AND content:boogie" it will know to parse,etc.

What I want to do it expand it so when they type a phrase in the 
textfield it will search select all at once and still be smart enough to 
recognize a lucene query.

For example,  say we have these fields:

to
from
content
subject

When I type "michael contract negotiation" it will look through all 
these fields and return hits.

Then it should be able to recognize more advance searches like:

to:michael AND content:foo

and not go through all fields....

Am I making sense?  Is this a good way to provide search?  How would I 
do this?

Thanks,
Michael


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



 
---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.