-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Search indexing properties question
PostPosted: Tue Aug 19, 2008 3:19 pm 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
I've read and tried many of the indexing options available, and still aren't quite getting what I need.

For example, if I have database table called "tblUtterance", with a column name "Line", the following is how I'm indexing...
Code:
Session session = this.hibernateTemplate.getSessionFactory().openSession();
        FullTextSession fullTextSession = Search.createFullTextSession(session);
        fullTextSession.getTransaction().begin();

        List<Utterance> utterances = session.createQuery("from Utterance").list();
        for (Utterance utterance : utterances) {
            fullTextSession.index(utterance);
        }


And this is my Utterance.java pojo. I also have this class extending another class where the @DocumentId is declared, so it is there as well.
Code:
@SuppressWarnings("serial")
@Entity
@Table(name = "tblUtterance", schema = "dbo")
@Indexed
@Analyzer(impl = WhitespaceAnalyzer.class)
public class Utterance extends UIDContainer {

    @Field(store = Store.YES, index = Index.TOKENIZED)
    @Column(name = "Line", nullable = false, length = 4000)
    private String line;


In the Luke tool, if a document that was indexed (a row in my table) is the following:
"Fine. How are you?"

I want to be able to search for the word "Fine" and have this utterance as a result, but nothing shows up. The only way it shows up is if I type the entire thing verbatim. Any ideas on how to have a true "full-text" index and search??

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 19, 2008 4:49 pm 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
I've figured it out using the online documentation as well as Hibernate Search in Action.

Its not even worth mentioning because I'm just a dummie sometimes...

Thanks to you who took the time to read this though. Definitely appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 20, 2008 4:29 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi danscrima,
I'm happy you solved it, but got curious.. so please, what was it?

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 20, 2008 6:05 am 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
I was indexing all wrong...

The top-level class needed @Indexed(index="indexName")
and I didnt need that for any of the other dependent classes. If you put @Indexed at the top of the other ones, it will created an additional index, and I wanted all my information to be in one to allow for easy searching.

So for an easy example, image my two classes, and I want them to be in the same index so I can search easily:
Code:
@Entity
@Table(name="tblPage",schema="dbo")
@Indexed(index="Library")
@Analyzer(impl = SimpleAnalyzer.class)
public class Pages{
    @Id
    @Column(name = "id", nullable = false, unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @DocumentId
    protected int id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "BookID", nullable = false)
    @IndexedEmbedded
    private Book book;
}

@Entity
@Table(name="tblBook",schema="dbo")
public class Book{
    @ContainedIn
    @OneToMany(mappedBy = "book")
    @Cascade(value = {CascadeType.SAVE_UPDATE})
    @Fetch(value = FetchMode.SUBSELECT)
    private List<Book> books= new ArrayList<Book>();
}


If you use Luke to analyze the index, you will see that each document will have a field "id" for the Page and a field "page.book.id" or something similar. I may have mixed them up but thats the general idea. Only one index is created.

Hope that helps... someone. Ha.


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