Search filter in sleep mode does not have expected results with Enum

I am using hibernate search 3.4 and I ran into a little problem. I have a filter that I am trying to use ( CourseStatusFilterFactory), but every time I turn it on, the results are not returned. I have another filter that works without problems ( DeletedFilterFactory), so I'm not sure what the problem is.

Here is the object I'm trying to execute.

@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Indexed
@FullTextFilterDefs({
    @FullTextFilterDef(name = "statusFilter", impl = CourseStatusFilterFactory.class, cache = FilterCacheModeType.NONE),
    @FullTextFilterDef(name = "deletedCourse", impl = DeletedFilterFactory.class, cache = FilterCacheModeType.NONE)})
public class Course extends LightEntity implements Serializable {

    private static final long serialVersionUID = 21L;
    @Id
    @DocumentId
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Field(name = "title", index = Index.TOKENIZED, store = Store.YES)
    private String title;
    @Field(name = "coursestatus", index = Index.TOKENIZED, store = Store.YES)
    @Enumerated(EnumType.STRING)
    private CourseStatus status;}

Any my FilterFactory:

public class CourseStatusFilterFactory {

private CourseStatus status;

public void setStatus(CourseStatus status) {
    this.status = status;
}

@Key
public FilterKey getKey() {
    StandardFilterKey key = new StandardFilterKey();
    key.addParameter(status);
    return key;
}

@Factory
public Filter getFilter() {
    String statusString = new EnumBridge().objectToString(this.status);
    Query query = new TermQuery(new Term("coursestatus", statusString));
    CachingWrapperFilter cachingWrapperFilter = new CachingWrapperFilter(new QueryWrapperFilter(query));
     return cachingWrapperFilter;
}}

and enable my filter:

persistenceQuery.enableFullTextFilter("statusFilter").setParameter("status", CourseStatus.PUBLISHED);

When you debug the code, I see that my query in the filter gets the value "coursestatus: PUBLISHED", but I still have 0 results, although there should be dozens.

Any ideas on where to start?

+3
source share
1 answer

hibernate .

@Field(name = "coursestatus", index = Index.TOKENIZED, store = Store.YES)

@Field(name = "coursestatus", index = Index.UN_TOKENIZED, store = Store.YES)
+3

All Articles