Lucilla는 Kotlin을위한 Memory In-Memory Full Text Search Library입니다.
데이터베이스에 지속될 필요가없는 데이터에 대한 전체 텍스트 검색 색인을 작성할 수 있습니다. 인덱스에 대해 검색 쿼리를 실행하여 일치하는 문서를 빠르게 찾을 수 있습니다.
import com.haroldadmin.lucilla.core.*
data class Book (
@Id
val id : Int ,
val title : String ,
val summary : String ,
)
val index = useFts(getBooks())
index.search( " Martian " ).map { searchResult ->
val bookId = searchResult.documentId
val book = getBook(bookId)
// Show search result to the user
}Lucilla는 적극적으로 개발 중입니다. 초기 단계 프로토 타입이며 아직 생산 사용에 적합하지 않습니다.
Lucilla는 대부분의 기본 기능을 다루었지만 일부 고급 기능에 대한 지원이 누락되었습니다 (그러나 계획).
Lucilla의 FTS 기능을 사용하려면 먼저 데이터를 클래스로 모델링해야합니다.
이 목적으로 데이터 클래스를 사용하는 것이 좋습니다. 그러나 다음 요구 사항을 충족하는 한 모든 것이 작동해야합니다.
Int 로 구문 분석 할 수있는 @Id 표시 필드가 있어야합니다.String s로 구문 분석 할 수있는 하나 이상의 다른 속성이 있어야합니다. import com.haroldadmin.lucilla.core.Id
data class Book (
@Id
val id : Int ,
val title : String ,
val summary : String ,
) Lucilla가 문서의 일부 필드를 색인화하기를 원하지 않으면 @Ignore 에 주석을 달 수 있습니다.
import com.haroldadmin.lucilla.core.Id
import com.haroldadmin.lucilla.core.Ignore
data class Book (
@Id
val id : Int ,
val title : String ,
val summary : String ,
@Ignore
val publisher : String ,
)FTS 인덱스를 작성하고 데이터를 추가하십시오.
val index = useFts< Book >()
getBooks().forEach { index.add(it) }
// You can also pass your seed data directly
val books = getBooks()
val index = useFts< Book >(books)인덱스에 문서를 추가하거나 시드 데이터로 인덱스를 만드는 것은 각 문서의 크기에 따라 잠재적으로 비싼 프로세스입니다. 배경 스레드 또는 코 루틴 에서이 프로세스를 수행하는 것이 가장 좋습니다.
쿼리를 색인으로 보내어 관련성으로 검색 결과를 주문하십시오.
val searchResults = index.search(query)
val books = searchResults.map { r -> r.documentId }.map { id -> getBook(id) }
showResults(books)Lucilla는 텍스트 처리 파이프 라인을 통해 모든 검색 쿼리를 실행하여 검색 가능한 토큰을 추출합니다. 토큰은 검색 쿼리를 정확하게 반영하지 않을 수 있습니다. 주어진 검색 결과와 일치하는 검색 쿼리의 토큰을 찾으려면 검색 결과에서 "Matcherter"속성을 사용하십시오.
저장소 목록에 Jitpack 저장소를 추가하십시오.
// Project level build.gradle file
allprojects {
repositories {
maven { url ' https://jitpack.io ' }
}
}그런 다음 Gradle 파일에 종속성을 추가하십시오.
// Module build.gradle file
dependencies {
implementation " com.github.haroldadmin.lucilla:core:(latest-version) "
}Lucilla는 적극적으로 개발 중이며 API 안정성을 약속하지 않습니다. 안정된 상태에 도달하기 전에 라이브러리가 상당한 변화를 겪을 것으로 예상하십시오.
우리는 커뮤니티가 기능을 제공하고 버그를보고하도록 권장합니다.
'Lucilla'라는 이름은 Sebastian Vettel의 2020 Ferrari라는 이름에서 영감을 받았습니다. 또한 업계 표준 전문 검색 프레임 워크 인 Lucene (Apache Lucene)과 비슷하게 들립니다.
Lucilla의 구현은 JavaScript Library Minisearch에서 차용합니다.
MIT License
Copyright (c) 2022 Kshitij Chauhan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.