-->
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: Facets and their counts not updated after insert new record
PostPosted: Fri Oct 02, 2015 1:33 pm 
Newbie

Joined: Fri Oct 02, 2015 12:51 pm
Posts: 2
Hi Everyone!

I have following dev env:

Wildfly 9.0.1.Final
Hibernate Core 4.3.0.Final
Hibernate Search 5.2.0.Final

I have observed that Facets and their count are not getting updated when insert new entity. However it got indexed automatically.
And search results are correct. But cannot see new facet until I re index full database.

Scenario is very simple i have following model

Business Category 1 -- * BusinessAccount and i am applying faceting request on businessCategory.name

Am i missing something in configuration? code can be provided if needed.
Please help me in this regard.

thanks,
Nabeel


Top
 Profile  
 
 Post subject: Re: Facets and their counts not updated after insert new record
PostPosted: Tue Oct 13, 2015 8:00 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi!
this should work without any particular configuration options. Could you share a test please?

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


Top
 Profile  
 
 Post subject: Re: Facets and their counts not updated after insert new record
PostPosted: Thu Oct 15, 2015 1:58 am 
Newbie

Joined: Fri Oct 02, 2015 12:51 pm
Posts: 2
Here is the code snippet:

@Entity
@Table(name = "BusinessCategory")
public class BusinessCategory {
@Field(analyze = Analyze.NO)
private String name;
}

@Entity
@Table(name = "BusinessAccount")
@Indexed
public class BusinessAccount {

@Field
@Column(name = "Title", length = 100, nullable = false, unique = true)
private String title;

@IndexedEmbedded
@ManyToOne
@JoinColumn(name = "BusinessCategoryID")
private BusinessCategory businessCategory;

}

public class AccountRepository {

public SearchResult findAccounts(String searchText) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);

// Create index for the first time
/* try {
fullTextEntityManager.createIndexer().startAndWait();
} catch (InterruptedException e) {
e.printStackTrace();
}*/

QueryBuilder builder = (QueryBuilder) fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(BusinessAccount.class).get();
org.apache.lucene.search.Query query = builder.keyword().onFields("title").matching(searchText).createQuery();

// making faceting request on field businessCategory.name
FacetContext facetContext = builder.facet();
FacetFieldContext facetFieldContext = facetContext.name("BusinessCategoryFacet");
FacetContinuationContext continuationContext = facetFieldContext.onField("businessCategory.name");
DiscreteFacetContext discreteFacetContext = continuationContext.discrete();
FacetParameterContext facetParameterContext = discreteFacetContext.orderedBy(FacetSortOrder.COUNT_DESC);
facetParameterContext.includeZeroCounts(Boolean.FALSE);
FacetingRequest categoryFacetingRequest = facetParameterContext.createFacetingRequest();

FullTextQuery persistenceQuery = fullTextEntityManager.createFullTextQuery(query, BusinessAccount.class);
FacetManager facetManager = persistenceQuery.getFacetManager();
facetManager.enableFaceting(categoryFacetingRequest);

List<BusinessAccount> accounts = persistenceQuery.getResultList();
int size = persistenceQuery.getResultSize();

List<Facet> facets = facetManager.getFacets("BusinessCategoryFacet");


}

}




Facets have old count which was at the time of indexing data. means first time. after new record insert count should be updated. But the search results are fine. i can see new record in search results.


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.