I do a TextQuery on my data that is text indexed
My Class
...
@TextIndexed(weight = 1f)
@Indexed
var name: String? = null
@TextIndexed(weight = 1f)
@Indexed
var lastName: String? = null
@TextIndexed(weight = 1f)
@Indexed
var phone: String? = null
@TextIndexed(weight = 1f)
@Indexed
var email: String? = null
...
My Config
val prospectTextIndex = TextIndexDefinitionBuilder()
.named("text_myclass_search")
.onField("name")
.onField("lastname")
.onField("phone")
.onField("email")
.build()
mongoTemplate()?.indexOps(MyClass::class.java)?.ensureIndex(myclassTextIndex)
My Repository
// Paginate over a full-text search result
fun findAllBy(textCriteria: TextCriteria?, pageable: Pageable?): Page<Prospect?>?
My Controller
val textCriteria: TextCriteria = TextCriteria
.forDefaultLanguage()
.matchingAny(searchQuery)
.caseSensitive(false)
val searchDirection: Sort = Sort.by(sortDirection, sortField)
val pageRequest: Pageable = PageRequest.of(pageRequested - 1, DEFAULT_PAGE_SIZE, searchDirection)
myclassRepository.findAllBy(
textCriteria,
pageRequest
)
I want to be able to search my TextIndex with characters in searchQuery like "J" or "goo" rather than full words or phrases, Is this possible ?