-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Creating multiple documents for the same entity
PostPosted: Mon Mar 28, 2011 4:58 pm 
Newbie

Joined: Mon Mar 28, 2011 4:52 pm
Posts: 2
Hi guys, i'm saving json data in the database as a clob field, and indexing all json properties using FieldBridge:
Quote:
myList:[
{"name": test1
"active":false
},
{"name": test2
"active":true
},
{"name": test3
"active":true
},
]


I'm indexing using a custom FieldBridge, using the format:
myList.name
myList.active

If i query to: +name:test1 +active:true will return the object, but it's wrong because the "test1" it's false.

So how can i do the search work individually for each entry of json, do i have to create 3 different documents? How can i create new documents in the FieldBridge implementation?


Top
 Profile  
 
 Post subject: Re: Creating multiple documents for the same entity
PostPosted: Tue Mar 29, 2011 6:17 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello,
it's not possible to store multiple documents for a single object. This is usually done by mapping this as a real list of objects, and "inverting" the map so that each element of the list is an indexed element.

In your case as it's mapped as single blobl object you could apply some other "tricks".

What about mapping this with multiple fieldnames:
"name_active: test1"
"name_notactive: test2"

Then when you perform a Query you can decide to search for the name_active or name_notactive fields, or both.

Or, in case you don't need to search on non-active elements, to just skip indexing the ones which are not enabled.

I'm sorry but the Lucene index is not relational, so you have to be clever and think about this kind of tricks. We're thinking into hacking the Lucene format for version 4 to make it more relational-friendly.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Creating multiple documents for the same entity
PostPosted: Tue Mar 29, 2011 9:21 am 
Newbie

Joined: Mon Mar 28, 2011 4:52 pm
Posts: 2
My field it's really a String and i persist as a Clob in the database.

I had thought about the tricks, but the problem is i do not know the json format, users are free to save any data they want.

The "trick" is the only way I can go? Why I must have just one document per object?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.