-->
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.  [ 14 posts ] 
Author Message
 Post subject: Search over all fields in all classes
PostPosted: Thu Apr 24, 2008 5:18 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
Hello
How can i search over all fields in every searchable class?
If I use
Code:
parser = new MultiFieldQueryParser(columnsTable, queryAnalyzer);

I need to pass columns list. It cannot be null.

If I use
Quote:
parser = new QueryParser(searchPattern, queryAnalyzer);

I don't know how to write query searching over any fields and any class.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 5:41 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I probably didn't understand your question,
are you saying you want to search for something bot don't know what?

Also you want to know the entity type (Class) you are searching for, at least some parent type.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 7:36 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
No :)
I want to search everywhere: on every class and every field


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 8:38 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you could define the same index on all your entities, and have all your fields named the same.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 9:11 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
it's impossible
properties (@IndexedEmbedded) are automatically named as field.target_field


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 9:48 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
properties (@IndexedEmbedded) are automatically named as field.target_field

the annotation has optional parameters, you may override the generated names.

Quote:
it's impossible

read the docs ;-)

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 7:24 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
I can override only one part of name. Worst, if my property is entity mapped 3 times (everytime using different analyzer with different name) I can only map to <my_name>.default_name using default analyzer only


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 2:33 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
so there is no possibility to search everywhere?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 2:55 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you have two options:
A) either you make a boolean OR query to look at all your fields
B) or you put all your data in the same field

for the case A) you should know the fieldnames, if you really don't know them you could look them up by using an IndexReader (see reference docs, 8.3) and use Lucene's API to get a list of Fields.

in case B you have to set all the fieldnames; for embedded properties you could use a @FieldBridge instead of (or in addition to) @IndexedEmbedded to have more control on the field name; also @ClassBridge could be useful for your purpose.

regards,

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 6:45 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
option B) have one big drawback - highlighting doesn't work as expected.
Let's say i map all fields under 'all' name.
Highlighting is based on reparsing stored document (I don't know how to force query to store term vectors), and TokenSources.getAnyTokenStream gets first created field with stored name 'all'.

So it's possible to highlight only one field in entity, every next field gets highlight positions wrong (from first field) and highlight bad position or make error Out Of the Bound Exception.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 11:17 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I never used the highlighter, so I can't help you with that but it looks like more a highlighter problem.

the IndexReader has a nice function getFieldNames(FieldOption.ALL), could you try searching in all defined fields?

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:29 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
I did my own function TokenSources.getTokenStream with additional parameter - text to parse. Original function always gets first field value with given name, so it highlights properly only first field.

I still doesn't know, why vectors are absent in field, but probably is more Lucene question.

Anyway I think HS should have highlighting built-in - all steps to do it are ready (for example: projection)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 5:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Marx2 wrote:
Anyway I think HS should have highlighting built-in - all steps to do it are ready (for example: projection)


What would the API look like?

Also putting all your data in one field is the safest way to do a search engine not that useful to your users. Some fields are more important than others depending on the use case / search. And you lose that info in strategy B

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 5:39 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
I simulate projection. So I take List of records (tables) from projection, and make every record (table) length bigger by one and put on this additional index highlighted text (of course treated with highlighter etc). It's simple but works.

Parsing queries, or collecting all possible field names is an option. But I give an option to user to search over text as is (only stopwords used), stemmed text or with synonyms. So many fileds are mapped three times with stored original text (to make highlighting working). Count of searchable fields is almost 500 in my app - Lucene had a problems with it.


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