File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
docs/documentation/database
src/test/scala/dev/mongocamp/driver/mongodb/lucene Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,10 @@ Like the Map to Bson conversion there is also an implicit method to convert `Que
1717
1818<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/lucene/LuceneSearchSpec.scala#lucene-parser-with-implicit
1919
20+ ### Parse String to Query
21+ We have an individual parser to parse an string to Lucene Query, because the default Lucene Analyser is case-insensitive and convert all search data into lower case. So the best way to seach in MongoDb with Lucene Query is to use this code.
22+
23+ <<< @/../src/test/scala/dev/mongocamp/driver/mongodb/lucene/LuceneSearchSpec.scala#lucene-parser
24+
2025## Read More
2126[ Lucene Cheatsheet] ( https://www.lucenetutorial.com/lucene-query-syntax.html )
Original file line number Diff line number Diff line change @@ -10,19 +10,21 @@ class LuceneSearchSpec extends PersonSpecification {
1010 " LuceneSearch" should {
1111
1212 " search with extended query" in {
13- // #region lucene-parser-with-explicit
1413 val luceneQuery = LuceneQueryConverter .parse(" (favoriteFruit:\" apple\" AND age:\" 25\" ) OR name:*Cecile* AND -active:false AND 123" , " id" )
15- val search = PersonDAO .find(LuceneQueryConverter .toDocument(luceneQuery), sortByBalance).resultList()
14+ // #region lucene-parser-with-explicit
15+ val search = PersonDAO .find(LuceneQueryConverter .toDocument(luceneQuery), sortByBalance).resultList()
1616 // #endregion lucene-parser-with-explicit
1717 search must haveSize(1 )
1818 search.head.age mustEqual 25
1919 search.head.name mustEqual " Terra Salinas"
2020 }
2121
2222 " search with extended query use implicit" in {
23- // #region lucene-parser-with-implicit
23+ // #region lucene-parser
2424 val luceneQuery = LuceneQueryConverter .parse(" (favoriteFruit:\" apple\" AND age:\" 25\" ) OR name:*Cecile* AND -active:false AND 123" , " id" )
25- val search = PersonDAO .find(luceneQuery, sortByBalance).resultList()
25+ // #endregion lucene-parser
26+ // #region lucene-parser-with-implicit
27+ val search = PersonDAO .find(luceneQuery, sortByBalance).resultList()
2628 // #endregion lucene-parser-with-implicit
2729 search must haveSize(1 )
2830 search.head.age mustEqual 25
You can’t perform that action at this time.
0 commit comments