-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search: Using TermQuery on CSV values
PostPosted: Fri Jun 12, 2009 11:15 am 
Newbie

Joined: Fri Oct 10, 2008 9:17 am
Posts: 13
Greetings,

Currently we have a field stored in the index as comma separated values, so the field looks something like this:

07a6d7137fc3c60e035011619b8e652c,e92ae301f19f0f0680e685ae91dfa6b2,ab5deecf01de4bb95f9717420babe25b


We want to be able to perform an exact match search on one of the values, like this:

Code:
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term("ids", "e92ae301f19f0f0680e685ae91dfa6b2" )), BooleanClause.Occur.MUST);

..etc



But this will not return any results despite the value existing in the field.

This is how the field is currently mapped:

Code:
@Field(index = org.hibernate.search.annotations.Index.TOKENIZED,store=Store.YES)
@FieldBridge(impl=CollectionToCSVBridge.class)
private Set<String> ids;



Any thoughts on how we can achieve this?


Top
 Profile  
 
 Post subject: Re: Hibernate Search: Using TermQuery on CSV values
PostPosted: Sat Jun 13, 2009 3:59 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
you have to consider what exactly is going to be inserted in your index; in the case of
Quote:
07a6d7137fc3c60e035011619b8e652c,e92ae301f19f0f0680e685ae91dfa6b2,ab5deecf01de4bb95f9717420babe25b

you want to make sure this String gets split at the appropriate points (the commas).

The most efficient solution is to use an Analyzer with a custom Tokenizer; it's the Tokenizer which will transform your free text in a sequence of tokens. I'd suggest to use the Luke tool to look into your index to verify how the text gets tokenized.

On the reference documentation you can find some examples of defining an Analyzer using a custom Tokenizer.

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


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