Hibernate lucene搜索包括“the”和“a”作为搜索的一部分

Hibernate lucene搜索包括“the”和“a”作为搜索的一部分,hibernate,search,hibernate-search,Hibernate,Search,Hibernate Search,我正在使用Hibernate Lucene索引一个表电影。我想按标题列进行索引和搜索,包括和作为搜索的一部分。前,最后一个被通缉的人。和A作为搜索结果的一部分是相关的 问题是如果我在@Field中使用了index=index.UN_标记,那么就无法进行搜索。若我使用Index.TOKENIZED,那个么我就不能使用和a进行搜索 有人能给我一些指导吗?提前谢谢 下面是代码片段: @Fieldindex=Index.UN_标记化,store=store.NO通过定义分析器,我认为这是一种解决方案。这

我正在使用Hibernate Lucene索引一个表电影。我想按标题列进行索引和搜索,包括和作为搜索的一部分。前,最后一个被通缉的人。和A作为搜索结果的一部分是相关的

问题是如果我在@Field中使用了index=index.UN_标记,那么就无法进行搜索。若我使用Index.TOKENIZED,那个么我就不能使用和a进行搜索

有人能给我一些指导吗?提前谢谢

下面是代码片段:


@Fieldindex=Index.UN_标记化,store=store.NO通过定义分析器,我认为这是一种解决方案。这将标记化,但不会排除通用词。 另外,在搜索代码中,使用方法QueryBuilder.phrase而不是关键字,以便根据搜索短语执行搜索

@AnalyzerDefname=custom,tokenizer=@TokenizerDeffactory=StandardTokenizerFactory.class,过滤器={ @TokenFilterDefactory=LowerCaseFilterFactory.class, @TokenFilterDefactory=SnowballPorterFilterFactory.class,params={@Parametername=language,value=English} 公映{

@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
@Analyzer(definition="custom")
private String title;
。。。 }

要搜索的代码: QueryBuilder qb=fullTextEntityMgr.getSearchFactory .buildQueryBuilder.forEntityMovie.class.get

Query luceneQuery=qb.phrase.onfieltitle.sentenceterm.toLowerCase.createQuery;
javax.persistence.Query Query=fullTextEntityMgr.createFullTextQueryluceneQuery,Movie.class

我想我通过定义分析器找到了解决方案
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
@Analyzer(definition="custom")
private String title;