Linking Fields to Documents possible?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Linking Fields to Documents possible?

sameerpatil
Hi,

  I have a requirement where I have a list of Suppliers(documents for lucene index) and a list of Products(documents again). Each Product has a supplier. e.g. :
Product -> RouterX, Supplier -> DLink, Netgear  
Product -> RouterY, Supplier -> Cisco

If I search for Cisco, RouterY should show up. If I implement the supplier as a Field in the Document - Router, I will have to update all the Products if the name of a Supplier changes.

Can I not just link the field - supplier in Product to the Supplier somehow rather than duplicating ??

-thanks
Reply | Threaded
Open this post in threaded view
|

Re: Linking Fields to Documents possible?

Ian Lea
Lucene is not a database.  You'll need to flatten the data and yes,
that does mean duplication.


--
Ian.


On Mon, Nov 23, 2009 at 9:05 AM, sameerpatil <[hidden email]> wrote:

>
> Hi,
>
>  I have a requirement where I have a list of Suppliers(documents for lucene
> index) and a list of Products(documents again). Each Product has a supplier.
> e.g. :
> Product -> RouterX, Supplier -> DLink, Netgear
> Product -> RouterY, Supplier -> Cisco
>
> If I search for Cisco, RouterY should show up. If I implement the supplier
> as a Field in the Document - Router, I will have to update all the Products
> if the name of a Supplier changes.
>
> Can I not just link the field - supplier in Product to the Supplier somehow
> rather than duplicating ??
>
> -thanks
> --
> View this message in context: http://old.nabble.com/Linking-Fields-to-Documents-possible--tp26474610p26474610.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Linking Fields to Documents possible?

Erick Erickson
In reply to this post by sameerpatil
There are some tricks you can apply, but they amount to
keeping your own lists and manipulating them manually. As Ian
says, Lucene isn't a database, and if you find yourself spending
much time trying to *make* it behave like a database you should
probably re-think your approach.

But in this case, you could say use an ID for your supplier and
keep a separate document with fields not in your usual schema
(remember, there's no requirement that all docs have the same
fields), read in and cache that document and use *it* to make
the correlation. Then, when your suppliers changed their names,
you'd only have to change one doc.

But then you have to look up your supplier names in the
document and substitute those IDs into your queries. And
use the "special" doc to lookup the names for display and.....
You see where this leads, each step in and of itself isn't
very hard, but pretty soon you're writing a RDMBS.

But is it worth it? How often does the supplier in your example
change their name? And how painful is reindexing? I've
often found that it's not that difficult to just reindex as necessary.

Best
Erick

On Mon, Nov 23, 2009 at 4:05 AM, sameerpatil <[hidden email]> wrote:

>
> Hi,
>
>  I have a requirement where I have a list of Suppliers(documents for lucene
> index) and a list of Products(documents again). Each Product has a
> supplier.
> e.g. :
> Product -> RouterX, Supplier -> DLink, Netgear
> Product -> RouterY, Supplier -> Cisco
>
> If I search for Cisco, RouterY should show up. If I implement the supplier
> as a Field in the Document - Router, I will have to update all the Products
> if the name of a Supplier changes.
>
> Can I not just link the field - supplier in Product to the Supplier somehow
> rather than duplicating ??
>
> -thanks
> --
> View this message in context:
> http://old.nabble.com/Linking-Fields-to-Documents-possible--tp26474610p26474610.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Linking Fields to Documents possible?

sameerpatil
Thanks guys, I get the point, it is best to reindex(hope it isnt very expensive). And yes, it's true that the suppliers dont change often. I