Skip to content

Commit 36bfe3b

Browse files
committed
Apply suggestions from peer review
1 parent 90d760e commit 36bfe3b

File tree

1 file changed

+13
-52
lines changed
  • content/develop/ai/search-and-query/advanced-concepts

1 file changed

+13
-52
lines changed

content/develop/ai/search-and-query/advanced-concepts/tags.md

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,31 @@ weight: 6
2020

2121
Tag fields provide exact match search capabilities with high performance and memory efficiency. Use tag fields when you need to filter documents by specific values without the complexity of full-text search tokenization.
2222

23-
## When to use tag fields
23+
Tag fields interpret text as a simple list of *tags* delimited by a [separator](#separator-options) character (comma "`,`" by default). This approach enables simpler [tokenization]({{< relref "/develop/ai/search-and-query/advanced-concepts/escaping/#tokenization-rules-for-tag-fields" >}}) and encoding, making tag indexes much more efficient than full-text indexes. Note: even though tag and text fields both use text, they are two separate field types and so you don't query them the same way.
2424

25-
Tag fields excel in scenarios requiring exact matching:
25+
## Tag fields vs text fields
26+
27+
Tag fields excel in scenarios requiring exact matching rather than full-text search. Choose tag fields when you need to index categorical data such as:
2628

2729
- **Product categories**: Electronics, Clothing, Books
2830
- **User roles**: Admin, Editor, Viewer
2931
- **Status values**: Active, Pending, Completed
3032
- **Geographic regions**: US, EU, APAC
3133
- **Content types**: Video, Image, Document
3234

33-
## Key advantages
34-
35-
Tag fields offer several benefits over TEXT fields:
36-
37-
1. **Exact match semantics** - Find documents with precise values
38-
2. **High performance** - Compressed indexes with minimal memory usage
39-
3. **Simple tokenization** - No stemming or complex text processing
40-
4. **Multiple values** - Support comma-separated lists in a single field
41-
5. **Case control** - Optional case-sensitive matching
35+
### Key differences
4236

43-
## Tag fields vs TEXT fields
44-
45-
| Feature | Tag Fields | TEXT Fields |
37+
| Feature | Tag fields | Text fields |
4638
|---------|------------|-------------|
4739
| **Search type** | Exact match | Full-text search |
4840
| **Tokenization** | Simple delimiter splitting | Complex word tokenization |
4941
| **Stemming** | None | Language-specific stemming |
5042
| **Memory usage** | Very low (1-2 bytes per entry) | Higher (frequencies, positions) |
5143
| **Performance** | Fastest | Slower for exact matches |
44+
| **Multiple values** | Support comma-separated lists | Single text content |
45+
| **Case control** | Optional case-sensitive matching | Typically case-insensitive |
5246
| **Use case** | Categories, filters, IDs | Content search, descriptions |
5347

54-
Tag fields interpret text as a simple list of *tags* delimited by a [separator](#separator-options) character (comma "`,`" by default). This approach enables simpler [tokenization]({{< relref "/develop/ai/search-and-query/advanced-concepts/escaping/#tokenization-rules-for-tag-fields" >}}) and encoding, making tag indexes much more efficient than full-text indexes.
55-
56-
**Important**: You can only access tag field values using special tag query syntax - they don't appear in general field-less searches.
57-
5848
## Technical details
5949

6050
### Index structure
@@ -274,16 +264,15 @@ FT.SEARCH products "@tags:{ Top\\ Rated\\ Product }"
274264

275265
### Best practices
276266

277-
1. **Use simple separators**: Stick to comma (`,`) or semicolon (`;`)
278-
2. **Avoid complex punctuation**: Keep tag values simple when possible
279-
3. **Test your queries**: Verify escaping works with your specific characters
280-
4. **Use consistent casing**: Decide on case sensitivity early in your design
267+
- **Use simple separators**: Stick to comma (`,`) or semicolon (`;`)
268+
- **Avoid complex punctuation**: Keep tag values simple when possible
269+
- **Test your queries**: Verify escaping works with your specific characters
270+
- **Use consistent casing**: Decide on case sensitivity early in your design
281271

282272
See [Query syntax]({{< relref "/develop/ai/search-and-query/advanced-concepts/query_syntax#tag-filters" >}}) for complete escaping rules.
283273

284-
## Common use cases
274+
## An e-commerce use case
285275

286-
### E-commerce filtering
287276
```sql
288277
# Product categories and attributes
289278
FT.CREATE products ON HASH PREFIX 1 product: SCHEMA
@@ -298,34 +287,6 @@ HSET product:1 name "Gaming Laptop" category "Electronics" brand "ASUS" features
298287
FT.SEARCH products "@category:{Electronics} @features:{RGB} @features:{SSD}"
299288
```
300289

301-
### User management
302-
```sql
303-
# User roles and permissions
304-
FT.CREATE users ON HASH PREFIX 1 user: SCHEMA
305-
name TEXT
306-
roles TAG SEPARATOR ","
307-
departments TAG SEPARATOR ","
308-
309-
HSET user:1 name "John Admin" roles "admin,editor" departments "IT,Security"
310-
311-
# Find users with admin access in IT
312-
FT.SEARCH users "@roles:{admin} @departments:{IT}"
313-
```
314-
315-
### Content classification
316-
```sql
317-
# Document tagging system
318-
FT.CREATE docs ON JSON PREFIX 1 doc: SCHEMA
319-
$.title AS title TEXT
320-
$.tags AS tags TAG SEPARATOR ","
321-
$.status AS status TAG
322-
323-
JSON.SET doc:1 $ '{"title":"API Guide","tags":"technical,guide,api","status":"published"}'
324-
325-
# Find published technical documents
326-
FT.SEARCH docs "@status:{published} @tags:{technical}"
327-
```
328-
329290
## Next steps
330291

331292
- Learn about [tokenization rules]({{< relref "/develop/ai/search-and-query/advanced-concepts/escaping#tokenization-rules-for-tag-fields" >}}) for tag fields

0 commit comments

Comments
 (0)