Last active
October 30, 2020 13:25
-
-
Save thjanssen/8f688bbf4d9f40e01234c8932abb7ce2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AnalyzerDef( | |
name = “textanalyzer”, | |
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), | |
filters = { | |
@TokenFilterDef(factory = LowerCaseFilterFactory.class), | |
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, | |
params = { @Parameter(name = “language”, value = “English”) }) | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(em); | |
QueryBuilder tweetQb = fullTextEm.getSearchFactory().buildQueryBuilder().forEntity(Tweet.class).get(); | |
Query fullTextQuery = tweetQb.keyword().onField(Tweet_.message.getName()).matching(searchTerm).createQuery(); | |
List<Tweet> results = fullTextEm.createFullTextQuery(fullTextQuery, Tweet.class).getResultList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Indexed | |
@Entity | |
public class Tweet { | |
@Column | |
@Field(analyzer = @Analyzer(definition = “textanalyzer”)) | |
private String message; | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment