Skip to content

RDoc-1627 + RDoc-3295 Indexing Metadata + Indexing ALL fields for FTS #2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,15 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and accessing Metadata",
"DiscussionId": "4566869a-8fa4-49a0-8875-0b82ddb45ed7",
"LastSupportedVersion": "5.4",
"Mappings": [
{
"Version": 2.0,
"Version": 2.5,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
},
{
"Version": 6.0,
"Key": "indexes/indexing-metadata"
}
]
},
Expand Down Expand Up @@ -220,4 +225,4 @@
"Name": "Troubleshooting",
"Mappings": []
}
]
]
11 changes: 6 additions & 5 deletions Documentation/3.5/Raven.Documentation.Pages/indexes/.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and accessing Metadata",
"DiscussionId": "08f5aae9-5159-419c-9ec2-bbd5b459097a",
"LastSupportedVersion": "5.4",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
{
"Version": 6.0,
"Key": "indexes/indexing-metadata"
}
]
},
{
Expand Down Expand Up @@ -220,4 +221,4 @@
"Name": "Troubleshooting",
"Mappings": []
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"LastSupportedVersion": "5.4",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
{
"Version": 6.0,
"Key": "indexes/indexing-metadata"
}
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,8 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
]
"LastSupportedVersion": "5.4",
"Mappings": []
},
{
"Path": "boosting.markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,8 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
]
"LastSupportedVersion": "5.4",
"Mappings": []
},
{
"Path": "boosting.markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,8 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
]
"LastSupportedVersion": "5.4",
"Mappings": []
},
{
"Path": "boosting.markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,11 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"LastSupportedVersion": "5.4",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
"Version": 6.0,
"Key": "indexes/indexing-metadata"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,8 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
]
"LastSupportedVersion": "5.4",
"Mappings": []
},
{
"Path": "rolling-index-deployment.markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,8 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
}
]
"LastSupportedVersion": "5.4",
"Mappings": []
},
{
"Path": "rolling-index-deployment.markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,11 @@
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"LastSupportedVersion": "5.4",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
"Version": 6.0,
"Key": "indexes/indexing-metadata"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@
"Mappings": []
},
{
"Path": "converting-to-json-and-accessing-metadata.markdown",
"Name": "Converting to JSON and Accessing Metadata",
"Path": "indexing-metadata.markdown",
"Name": "Indexing Metadata",
"DiscussionId": "2fe7313c-df13-478b-acd3-08c5b4d21a1d",
"Mappings": [
{
"Version": 2.0,
"Key": "client-api/querying/static-indexes/defining-static-index#using--and-"
"Version": 3.0,
"Key": "indexes/converting-to-json-and-accessing-metadata"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Indexing Metadata
---

{NOTE: }

* Each document in the database includes a metadata section, stored in a special JSON object under the `@metadata` property.

* This metadata is not part of the document's content but holds internal system information (used by RavenDB),
such as the document ID, collection name, change vector, last modified timestamp, and more,
as well as optional user-defined entries.

* To learn how to access (get and modify) the metadata from your client code,
see [How to get and modify the metadata](../client-api/session/how-to/get-and-modify-entity-metadata).

* Content from metadata properties can be extracted and **indexed** within a static index, alongside content from the document fields.
This allows you to query for documents based on values stored in the metadata.
See the examples below.

---

* In this article:
* [Indexing metadata properties](../indexes/indexing-metadata#indexing-metadata-properties)
* [Metadata properties that can be indexed](../indexes/indexing-metadata#metadata-properties-that-can-be-indexed)

{NOTE/}

---

{PANEL: Indexing metadata properties}

* Use the `MetadataFor` method to access a document's metadata within the index definition,
as shown in the example below.

* You can retrieve metadata values using one of two syntaxes:

* **Generic method syntax**
Use `Value<T>()` to retrieve and cast the metadata value to the expected type.
This is type-safe and preferred when the type is known (e.g., _DateTime_).
* **Indexer syntax**
Use `metadata["key"]` to retrieve the raw object.
You can cast it manually if needed.

---

* The following index definition indexes content from the `@last-modified` and `@counters` metadata properties.

{CODE-TABS}
{CODE-TAB:csharp:LINQ_index_accessMetadataViaValue index_1@Indexes/Metadata.cs /}
{CODE-TAB:csharp:LINQ_index_accessMetadataViaIndexer index_2@Indexes/Metadata.cs /}
{CODE-TAB:csharp:JS_index index_3@Indexes/Metadata.cs /}
{CODE-TABS/}

* Query for documents based on metadata values:
Retrieve documents that have counters and order them by their last modified timestamp.

{CODE-TABS}
{CODE-TAB:csharp:Query query_1@Indexes/Metadata.cs /}
{CODE-TAB:csharp:Query_async query_1_async@Indexes/Metadata.cs /}
{CODE-TAB:csharp:DocumentQuery query_2@Indexes/Metadata.cs /}
{CODE-TAB-BLOCK:sql:RQL}
from index "Products/ByMetadata/AccessViaValue"
where HasCounters == true
order by LastModified desc
{CODE-TAB-BLOCK/}
{CODE-TABS/}

{PANEL/}

{PANEL: Metadata properties that can be indexed}

* The table below lists **predefined metadata properties that can be indexed**.

* Each property can be accessed using either a string literal (e.g. `"@last-modified"`) or the corresponding Client API constant (e.g. `Raven.Client.Constants.Documents.Metadata.LastModified`).
Using the Client API constant is recommended for clarity and to avoid typos.

* You can add custom metadata properties to any document as needed.
These custom properties can be indexed just like the predefined ones.

| String literal | Client API Constant |
|---------------------|--------------------------------------------------------|
| `@archive-at` | Raven.Client.Constants.Documents.Metadata.ArchiveAt |
| `@attachments` | Raven.Client.Constants.Documents.Metadata.Attachments |
| `@change-vector` | Raven.Client.Constants.Documents.Metadata.ChangeVector |
| `@collection` | Raven.Client.Constants.Documents.Metadata.Collection |
| `@counters` | Raven.Client.Constants.Documents.Metadata.Counters |
| `@etag` | Raven.Client.Constants.Documents.Metadata.Etag |
| `@expires` | Raven.Client.Constants.Documents.Metadata.Expires |
| `@id` | Raven.Client.Constants.Documents.Metadata.Id |
| `@last-modified` | Raven.Client.Constants.Documents.Metadata.LastModified |
| `@refresh` | Raven.Client.Constants.Documents.Metadata.Refresh |
| `@timeseries` | Raven.Client.Constants.Documents.Metadata.TimeSeries |
| `Raven-Clr-Type` | Raven.Client.Constants.Documents.Metadata.RavenClrType |

{WARNING: }

Note:

* The `@attachments` metadata property can only be indexed using a **Lucene** index.
* The **Corax** search engine does not support indexing complex JSON properties.
Learn more in [Corax: Handling complex JSON objects](../indexes/search-engine/corax#handling-of-complex-json-objects).

{WARNING/}
{PANEL/}

## Related articles

### Indexes

- [Indexing Basics](../indexes/indexing-basics)

### Client API

- [How to get and modify the metadata](../client-api/session/how-to/get-and-modify-entity-metadata)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Indexing Metadata
---

{NOTE: }

* Each document in the database includes a metadata section, stored in a special JSON object under the `@metadata` property.

* This metadata is not part of the document's content but holds internal system information (used by RavenDB),
such as the document ID, collection name, change vector, last modified timestamp, and more,
as well as optional user-defined entries.

* To learn how to access (get and modify) the metadata from your client code,
see [How to get and modify the metadata](../client-api/session/how-to/get-and-modify-entity-metadata).

* Content from metadata properties can be extracted and **indexed** within a static index, alongside content from the document fields.
This allows you to query for documents based on values stored in the metadata.
See the examples below.

---

* In this article:
* [Indexing metadata properties](../indexes/indexing-metadata#indexing-metadata-properties)

{NOTE/}

---

{PANEL: Indexing metadata properties}

{CODE:java index_1@Indexes/Metadata.java /}

{CODE:java query_1@Indexes/Metadata.java /}

{PANEL/}

## Related articles

### Indexes

- [Indexing Basics](../indexes/indexing-basics)

### Client API

- [How to get and modify the metadata](../client-api/session/how-to/get-and-modify-entity-metadata)
Loading
Loading