An Interesting Search Problem


(David Jensen-2) #1

The follow example is a search problem that I'm trying to solve. This
is example is more of an analogy but it should get the point across.

I have a master index of different beer selections. It has fields like
the name of the beer, "Torpedo Extra IPA," the brewery, "Sierra
Nevada," the abv, the color, the style, an official description, and
more. Some breweries will change the details of some of these beers
from year to year so this information would preferably live in only
one index.

Next, each user has their own index of beer. In this index the user
may include different details for each of beer fields. Most notably
would be description. The user will very likely have their own
specific notes for description.

Let's take the Torpedo Extra IPA example. The master index has the
following document,

{
_id: 1980,
name: "Torpedo Extra IPA",
brewery: "Sierra Nevada",
style: "IPA",
description: "Sierra Nevada Torpedo Ale is a big American IPA;
bold, assertive and full of flavor and aromas highlighting the complex
citrus, pine and herbal character of whole-cone American hops."
}

Let's say the user document is as follows ...

{
_id: 1980,
description: "Hoppy, floral orange notes with a malty character
balanced by a sharp spicy bitter hop bite. Contains Citra hops."
}

The easiest way to describe how I want the results is likely the wrong
way of thinking about the problem, but it's very clear to understand.
I would like to basically search on description, joining on _id,
showing the data from the master record in the results. But it's a
little more complicated than that. I actually want the "joined"
results to appear first (let's say on average there are 5-10 of
these), results only in the user index next, followed by results from
only the master index.

I've thought of a few different way of doing this but I'd like to hear
some other hopefully better ideas. I'm also willing to listen to
"you're making it too complicated do this instead."


(Shay Banon) #2

Hi,

If I got it correctly, it sounds like you will need to execute two
queries (one against the user index, and one against the master index), and
do the joining on the client side. Note that you might need to duplicate the
master information on each user index if you want to match on that.

Another option is to create a single index, with "user" field for a
document, the master will be a special "master" user. Then, you do a
single search, and get back the relevant results back. You can filter the
query with one that only matches on "master" and the user in question.

-shay.banon

On Tue, Aug 24, 2010 at 9:25 PM, David Jensen djensen47@gmail.com wrote:

The follow example is a search problem that I'm trying to solve. This
is example is more of an analogy but it should get the point across.

I have a master index of different beer selections. It has fields like
the name of the beer, "Torpedo Extra IPA," the brewery, "Sierra
Nevada," the abv, the color, the style, an official description, and
more. Some breweries will change the details of some of these beers
from year to year so this information would preferably live in only
one index.

Next, each user has their own index of beer. In this index the user
may include different details for each of beer fields. Most notably
would be description. The user will very likely have their own
specific notes for description.

Let's take the Torpedo Extra IPA example. The master index has the
following document,

{
_id: 1980,
name: "Torpedo Extra IPA",
brewery: "Sierra Nevada",
style: "IPA",
description: "Sierra Nevada Torpedo Ale is a big American IPA;
bold, assertive and full of flavor and aromas highlighting the complex
citrus, pine and herbal character of whole-cone American hops."
}

Let's say the user document is as follows ...

{
_id: 1980,
description: "Hoppy, floral orange notes with a malty character
balanced by a sharp spicy bitter hop bite. Contains Citra hops."
}

The easiest way to describe how I want the results is likely the wrong
way of thinking about the problem, but it's very clear to understand.
I would like to basically search on description, joining on _id,
showing the data from the master record in the results. But it's a
little more complicated than that. I actually want the "joined"
results to appear first (let's say on average there are 5-10 of
these), results only in the user index next, followed by results from
only the master index.

I've thought of a few different way of doing this but I'd like to hear
some other hopefully better ideas. I'm also willing to listen to
"you're making it too complicated do this instead."


(system) #3