Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
b78569f6
Commit
b78569f6
authored
Dec 07, 2017
by
rajeshsubhankar
Committed by
Marc Gravell
Dec 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature/NRediSearch-TAGS (#749)
* Tag feature added
parent
e0810eed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
611 additions
and
553 deletions
+611
-553
Client.cs
NRediSearch/Client.cs
+445
-420
Schema.cs
NRediSearch/Schema.cs
+166
-133
No files found.
NRediSearch/Client.cs
View file @
b78569f6
...
@@ -138,6 +138,31 @@ public async Task<SearchResult> SearchAsync(Query q)
...
@@ -138,6 +138,31 @@ public async Task<SearchResult> SearchAsync(Query q)
return
new
SearchResult
(
resp
,
!
q
.
NoContent
,
q
.
WithScores
,
q
.
WithPayloads
);
return
new
SearchResult
(
resp
,
!
q
.
NoContent
,
q
.
WithScores
,
q
.
WithPayloads
);
}
}
/// <summary>
/// Return Distinct Values in a TAG field
/// </summary>
/// <param name="fieldName">TAG field name</param>
/// <returns>List of TAG field values</returns>
public
RedisValue
[]
TagVals
(
string
fieldName
)
{
var
resp
=
(
RedisValue
[])
DbSync
.
Execute
(
"FT.TAGVALS"
,
_boxedIndexName
,
fieldName
);
return
resp
;
}
/// <summary>
/// Return Distinct Values in a TAG field
/// </summary>
/// <param name="fieldName">TAG field name</param>
/// <returns>List of TAG field values</returns>
public
async
Task
<
RedisValue
[
]>
TagValsAsync
(
string
fieldName
)
{
var
resp
=
(
RedisValue
[])
await
_db
.
ExecuteAsync
(
"FT.TAGVALS"
,
_boxedIndexName
,
fieldName
).
ConfigureAwait
(
false
);
return
resp
;
}
/// <summary>
/// <summary>
/// Add a single document to the query
/// Add a single document to the query
/// </summary>
/// </summary>
...
...
NRediSearch/Schema.cs
View file @
b78569f6
...
@@ -15,7 +15,8 @@ public enum FieldType
...
@@ -15,7 +15,8 @@ public enum FieldType
{
{
FullText
,
FullText
,
Geo
,
Geo
,
Numeric
Numeric
,
Tag
}
}
public
class
Field
public
class
Field
...
@@ -40,6 +41,7 @@ object GetForRedis(FieldType type)
...
@@ -40,6 +41,7 @@ object GetForRedis(FieldType type)
case
FieldType
.
FullText
:
return
"TEXT"
.
Literal
();
case
FieldType
.
FullText
:
return
"TEXT"
.
Literal
();
case
FieldType
.
Geo
:
return
"GEO"
.
Literal
();
case
FieldType
.
Geo
:
return
"GEO"
.
Literal
();
case
FieldType
.
Numeric
:
return
"NUMERIC"
.
Literal
();
case
FieldType
.
Numeric
:
return
"NUMERIC"
.
Literal
();
case
FieldType
.
Tag
:
return
"TAG"
.
Literal
();
default
:
throw
new
ArgumentOutOfRangeException
(
nameof
(
type
));
default
:
throw
new
ArgumentOutOfRangeException
(
nameof
(
type
));
}
}
}
}
...
@@ -129,5 +131,36 @@ public Schema AddSortableNumericField(string name)
...
@@ -129,5 +131,36 @@ public Schema AddSortableNumericField(string name)
return
this
;
return
this
;
}
}
public
class
TagField
:
Field
{
public
string
Separator
{
get
;
}
internal
TagField
(
string
name
,
string
separator
=
","
)
:
base
(
name
,
FieldType
.
Tag
,
false
)
{
Separator
=
separator
;
}
internal
override
void
SerializeRedisArgs
(
List
<
object
>
args
)
{
base
.
SerializeRedisArgs
(
args
);
if
(
Separator
!=
","
)
{
args
.
Add
(
"SEPARATOR"
.
Literal
());
args
.
Add
(
Separator
);
}
}
}
/// <summary>
/// Add a TAG field
/// </summary>
/// <param name="name">the field's name</param>
/// <param name="separator">tag separator</param>
/// <returns>the schema object</returns>
public
Schema
AddTagField
(
string
name
,
string
separator
=
","
)
{
Fields
.
Add
(
new
TagField
(
name
,
separator
));
return
this
;
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment