-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement FullTextIndex and FullTextExpression (#75)
- Loading branch information
Showing
8 changed files
with
271 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
part of couchbase_lite; | ||
|
||
class FullTextExpressionIndex { | ||
final String _name; | ||
FullTextExpressionIndex._(this._name); | ||
|
||
FullTextExpression match(String query) { | ||
return FullTextExpression._match(_name, query); | ||
} | ||
} | ||
|
||
class FullTextExpression extends Object with Expression { | ||
static FullTextExpressionIndex index(String name) { | ||
return FullTextExpressionIndex._(name); | ||
} | ||
|
||
factory FullTextExpression.rank(String indexName) { | ||
final expression = FullTextExpression._(); | ||
expression._internalExpressionStack.add({'rank': indexName}); | ||
return expression; | ||
} | ||
|
||
FullTextExpression._(); | ||
|
||
FullTextExpression._match(String indexName, String query) { | ||
_internalExpressionStack.add({ | ||
'fullTextMatch': [indexName, query], | ||
}); | ||
} | ||
|
||
FullTextExpression._clone(FullTextExpression expression) { | ||
_internalExpressionStack.addAll(expression.internalExpressionStack); | ||
} | ||
|
||
@override | ||
FullTextExpression _clone() { | ||
return FullTextExpression._clone(this); | ||
} | ||
} |
c9102f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no example of how to add this Index to the database I guess but not sure it is like this @bangfalse bangfalse @bawelter @tediyuwono @SaltechDevelopers @lchristille
Correct me if I am wrong
c9102f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to use
FullTextIndexItem
andIndexBuilder.fullTextIndex
to build an FTS index. An example usage looks like this:This follows the project's stated goal:
Note that only properties can currently be indexed by Couchbase Lite FTS, not expressions.