-->
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.  [ 7 posts ] 
Author Message
 Post subject: [hibernate search] how to store a field twice
PostPosted: Wed Jul 04, 2007 12:14 pm 
Newbie

Joined: Wed Jul 04, 2007 12:03 pm
Posts: 14
i would like to have a single lucene field that has mutliple object properties indexed for easy searching accross multiple properties in tokenized way, but some of those fields also have to be indexed untokenized under the property name.

I would like to write something like this :

@Field(name="all", index=Index.TOKENIZED, store=Store.NO)
@Field(name="from", index=Index.UNTOKENIZED, store=Store.YES)
public String getFrom() { ... }

how can this be achieved?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 4:36 am 
Newbie

Joined: Fri Jun 29, 2007 5:01 am
Posts: 12
hi,

how about this:

@Field(name="from", index=Index.UNTOKENIZED, store=Store.YES)
public String getFrom() { ... }

@Field(name="all", index=Index.TOKENIZED, store=Store.NO)
public String getAll(){
return getFrom();
}


Top
 Profile  
 
 Post subject: clarification
PostPosted: Mon Jul 09, 2007 5:18 am 
Newbie

Joined: Wed Jul 04, 2007 12:03 pm
Posts: 14
hi true,

let me be more specific, the " all " property should contain the tokenized content of several propertie ( a single combined property to search on )

the below is working but it would still be much nicer to be able to annotate a single property twice (would be preferred to to artificial getters)

thax for the reaction

current solution :

@Field(name="from", index=Index.UNTOKENIZED, store=Store.YES)
public String getFrom() { ... }

@Field(name="all", index=Index.TOKENIZED, store=Store.NO)
public String getFromAll(){
return getFrom();

@Field(name="to", index=Index.UNTOKENIZED, store=Store.YES)
public String getFrom() { ... }

@Field(name="all", index=Index.TOKENIZED, store=Store.NO)
public String getToAll(){
return getFrom();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 8:37 am 
Newbie

Joined: Fri Jun 29, 2007 5:01 am
Posts: 12
mh, maybe i dont get the point:

why do you even want to index a field twice? A tokenized field will just break up your text for that field and generate matches for every token in a query. And for the search accross multiple fields, there is the MultiFieldQueryParser which takes an array of fields to search in...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 8:49 am 
Newbie

Joined: Wed Jul 04, 2007 12:03 pm
Posts: 14
the reasons why is explained in

The All Field
You also ought to really think about glomming all of the Field data together and storing it as some sort of "all" Field. This is the easiest way to set it up so your users can search all Fields at once, if they want. Yes, you could come up with a complex scheme to rewrite your users' query so it searches across all of the known fields, but remember, keep it simple

from http://darksleep.com/lucene/

thank you for the reference to the multifieldqueryparser. i guess that in hibernate search context this could be more appropriate than building an 'ALL' field, however, in terms of query performance, i recall some statements that the 'all' field approach would be better.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Fields will be introduced soon
But wrt your problem, I think "all" is a bad idea. It prevent you from boosting one field over another one (all of them considered equals). The MultifieldQueryParser is much more flexible and adjustable per usecase.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As for query perfs, fast enough is what you should target

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.