prem111
December 10, 2022, 4:33am
1
I am using Couchbase Lite 3.0.2 version, ASP .Net Core 6
I have the below query and FTS index. But am getting extact match instead of all the words having the searchString.
var indexFields = new string { “OrderNUmber”, “Category” };
_couchbaseRepository.CreateFTSIndex(“FTSIndex”, indexFields);
var queryStr = "SELECT * FROM buck" +
"WHERE type='doc' AND ownerId = '" + id.ToString() + "' " +
"AND MATCH(FTSIndex, \"*" + searchString + "*\") " +
"ORDER BY OrderNumber";
I tested
db.CreateIndex("sentence", IndexBuilder.FullTextIndex(FullTextIndexItem.Property("sentence")));
var q = db.CreateQuery("SELECT _id FROM _ WHERE MATCH(sentence, 'searchStr1 searchStr2 searchStr3')")
and I have no problem of getting
"xxxxx searchStr2 xxxxxxxxx searchStr1 xxxxxx searchStr3"
as one of returned searched result.
pasin
December 12, 2022, 1:16am
3
Couchbase Lite FTS is based on SQLite’s FTS. Here is the document about what you can use in the query text : SQLite FTS3 and FTS4 Extensions .
“ ” will work in FTS. You can only do prefix search with “*”. So means that you are searching the text that has * prefix.
prem111
December 14, 2022, 10:45am
4
@pasin @Sandy_Chuang Thank you so much.