lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <>
Subject Re: Multiple Field search
Date Tue, 06 May 2008 16:32:43 GMT
One of my favorite quotes from Roger Zelazny... "postulating
infinity, the rest is easy".

In this case, "infinity" is how you break up your query. The easy part is
making your search return what you want.

Assuming you know that you want "greatest" and
"hits" to go against the title field and "beatles" to
go against description, your query looks something

+title:greatest +title:hits +description:beatles

But knowing you want to break up the query like that is the hard part.

Sometimes you can make it work well enough by submitting all
terms against both fields with an OR clause, something like:

title:(+greatest +hits +beatles) description:(+greatest +hits +beatles)
(note, OR is implied between title and description)

which would not work in your case. Another technique is to dump
all the words into a single uber-field *as well as* your individual
fields, so the search
uber:(+greatest +hits +beatles) would work for you. Note that if
you index (but do NOT store) the uber field and store (but do NOT index)
the text and description fields, your index stays about the same size.....

Anyway, you need to carefully define how your searches *should* work,
then define your index structure IMO.


On Tue, May 6, 2008 at 12:07 PM, Kelvin Foo Chuan Lyi <>

> I'm new to lucene and have a question on how to create a query for the
> following example... Say I have two fields, Title and Description, with
> the
> following data
> Item 1
> Title: The greatest hits
> Description : Collection of the best music from The Beatles.
> Item 2
> Title: U2 collections
> Description : Greatest hits collection of U2
> In my search, I want to search for 'greatest hits beatles'. The result
> should return only Item 1..  how should the query looks like??
> Thanks.
> --
> Sayonara,
> Kelvin

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message