Skip to content

Commit 1e08a30

Browse files
authored
Merge pull request #1985 from reebhub/PHP_indexBatch2
[PHP] Indexing pages batch [Replace C# samples]
2 parents 3f58cab + 5867105 commit 1e08a30

38 files changed

+8629
-6
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Indexes: Boosting
2+
---
3+
4+
{NOTE: }
5+
6+
* When querying with some filtering conditions, a basic **score** is
7+
calculated by the underlying engine for each document in the results.
8+
9+
* Providing a **boost value** to selected fields allows prioritization of the resulting documents.
10+
The boos value is integrated with the basic score, increasing the document rank.
11+
12+
* The automatic ordering of results by their score is [configurable](../indexes/boosting#automatic-score-based-ordering).
13+
14+
* Boosting can be achieved in the following ways:
15+
16+
* **At query time**:
17+
By applying a boost factor to searched terms at query time (see [Boost search results](../client-api/session/querying/text-search/boost-search-results)).
18+
19+
* **Via index definition**:
20+
By applying a boost factor in the index definition, as described in this article.
21+
22+
* In this page:
23+
* [Assign a boost factor to an index-field](../indexes/boosting#assign-a-boost-factor-to-an-index-field)
24+
* [Assign a boost factor to the index-entry](../indexes/boosting#assign-a-boost-factor-to-the-index-entry)
25+
* [Automatic score-based ordering](../indexes/boosting#automatic-score-based-ordering)
26+
27+
{NOTE/}
28+
29+
---
30+
31+
{PANEL: Assign a boost factor to an index-field}
32+
33+
Applying a boost value to an index-field allows prioritization of matching documents based on an index-field.
34+
35+
---
36+
37+
38+
##### The index:
39+
40+
{CODE-TABS}
41+
{CODE-TAB:php:LINQ_index index_1@Indexes\Boosting.php /}
42+
{CODE-TAB:php:JavaScript_index index_1_js@Indexes\Boosting.php /}
43+
{CODE-TABS/}
44+
45+
##### The query:
46+
47+
{CODE-TABS}
48+
{CODE-TAB:php:Query query_1@Indexes\Boosting.php /}
49+
{CODE-TAB:php:DocumentQuery query_3@Indexes\Boosting.php /}
50+
{CODE-TAB-BLOCK:sql:RQL}
51+
from index "Orders/ByCountries/BoostByField"
52+
where ShipToCountry == "poland" or CompanyCountry == "portugal"
53+
{CODE-TAB-BLOCK/}
54+
{CODE-TABS/}
55+
56+
{PANEL/}
57+
58+
{PANEL: Assign a boost factor to the index-entry}
59+
60+
Applying a boost value to the whole index-entry allows prioritization of matching documents by content from the document.
61+
62+
---
63+
64+
##### The index:
65+
66+
{CODE-TABS}
67+
{CODE-TAB:php:LINQ_index index_2@Indexes\Boosting.php /}
68+
{CODE-TAB:php:JavaScript_index index_2_js@Indexes\Boosting.php /}
69+
{CODE-TABS/}
70+
71+
##### The query:
72+
73+
{CODE-TABS}
74+
{CODE-TAB:php:Query query_4@Indexes\Boosting.php /}
75+
{CODE-TAB:php:DocumentQuery query_6@Indexes\Boosting.php /}
76+
{CODE-TAB-BLOCK:sql:RQL}
77+
from index "Orders/ByCountries/BoostByIndexEntry"
78+
where ShipToCountry == "poland" or CompanyCountry == "portugal"
79+
{CODE-TAB-BLOCK/}
80+
{CODE-TABS/}
81+
82+
{PANEL/}
83+
84+
{PANEL: Automatic score-based ordering}
85+
86+
* By default, whenever boosting is applied, either via dynamic querying or when querying an index
87+
that has a boosting factor in its definition, the results will be automatically ordered by the score.
88+
89+
* This behavior can be modified using the [OrderByScoreAutomaticallyWhenBoostingIsInvolved](../server/configuration/indexing-configuration#indexing.orderbyscoreautomaticallywhenboostingisinvolved)
90+
configuration key.
91+
92+
* Refer to the [Get resulting score](../client-api/session/querying/sort-query-results#get-resulting-score)
93+
section to learn how to retrieve the calculated score of each result.
94+
95+
{PANEL/}
96+
97+
## Related Articles
98+
99+
### Querying
100+
101+
- [Full-text search](../client-api/session/querying/text-search/full-text-search)
102+
- [Boost search results](../client-api/session/querying/text-search/boost-search-results)
103+
104+
### Indexes
105+
106+
- [Analyzers](../indexes/using-analyzers)
107+
- [Storing Data in Index](../indexes/storing-data-in-index)
108+
- [Term Vectors](../indexes/using-term-vectors)
109+
- [Dynamic Fields](../indexes/using-dynamic-fields)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Indexes: Converting to JSON and Accessing Metadata
2+
3+
---
4+
{NOTE: }
5+
6+
Entities passed to an index can be converted to JSON using the `AsJson` method.
7+
It is also possible to access metadata for a specified object using the `MetadataFor` method.
8+
9+
* In this Page:
10+
* [AsJson - Converting to JSON](../indexes/converting-to-json-and-accessing-metadata#asjson---converting-to-json)
11+
* [MetadataFor - Accessing Metadata](../indexes/converting-to-json-and-accessing-metadata#metadatafor---accessing-metadata)
12+
13+
{NOTE/}
14+
15+
---
16+
17+
{PANEL: AsJson - Converting to JSON}
18+
19+
{CODE:php indexes_1@Indexes/Metadata.php /}
20+
21+
{CODE:php indexes_2@Indexes/Metadata.php /}
22+
23+
{PANEL/}
24+
25+
{PANEL: MetadataFor - Accessing Metadata}
26+
27+
{CODE:php indexes_3@Indexes/Metadata.php /}
28+
29+
{CODE:php indexes_4@Indexes/Metadata.php /}
30+
31+
{PANEL/}
32+
33+
## Related articles
34+
35+
### Indexes
36+
37+
- [Indexing Basics](../indexes/indexing-basics)
38+
39+
### Client API
40+
41+
- [How to Get and Modify Entity Metadata](../client-api/session/how-to/get-and-modify-entity-metadata)

Documentation/5.4/Raven.Documentation.Pages/indexes/indexing-hierarchical-data.dotnet.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where Authors == "Moon"
9292
{CODE-TAB-BLOCK/}
9393
{CODE-TABS/}
9494

95-
**Query the index using the Studio**:
95+
**Query the index using Studio**:
9696

9797
* Query the index from the Studio's [List of Indexes](../studio/database/indexes/indexes-list-view#indexes-list-view) view:
9898

Documentation/5.4/Raven.Documentation.Pages/indexes/indexing-hierarchical-data.js.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ where authors == "Moon"
8989
{CODE-TAB-BLOCK/}
9090
{CODE-TABS/}
9191

92-
**Query the index using the Studio**:
92+
**Query the index using Studio**:
9393

9494
* Query the index from the Studio's [List of Indexes](../studio/database/indexes/indexes-list-view#indexes-list-view) view:
9595

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Indexing Hierarchical Data
2+
---
3+
4+
{NOTE: }
5+
6+
* Use the `Recurse` method to traverse the layers of a hierarchical document and index its fields.
7+
8+
* In this Page:
9+
* [Hierarchical data](../indexes/indexing-hierarchical-data#hierarchical-data)
10+
* [Index hierarchical data](../indexes/indexing-hierarchical-data#index-hierarchical-data)
11+
* [Query the index](../indexes/indexing-hierarchical-data#query-the-index)
12+
13+
{NOTE/}
14+
15+
---
16+
17+
{PANEL: Hierarchical data}
18+
19+
One significant advantage of document databases is their tendency not to impose limits on data structuring.
20+
**Hierarchical data structures** exemplify this quality well; for example, consider the commonly used comment thread, implemented using objects such as:
21+
22+
{CODE:php indexes_1@Indexes\IndexingHierarchicalData.php /}
23+
24+
Readers of a post created using the above `BlogPost` structure can add `BlogPostComment` entries to the post's _comments_ field,
25+
and readers of these comments can reply with comments of their own, creating a recursive hierarchical structure.
26+
27+
For example, the following document, `BlogPosts/1-A`, represents a blog post by John that contains multiple layers of comments from various authors.
28+
29+
`BlogPosts/1-A`:
30+
31+
{CODE-BLOCK:JSON}
32+
{
33+
"Author": "John",
34+
"Title": "Post title..",
35+
"Text": "Post text..",
36+
"Comments": [
37+
{
38+
"Author": "Moon",
39+
"Text": "Comment text..",
40+
"Comments": [
41+
{
42+
"Author": "Bob",
43+
"Text": "Comment text.."
44+
},
45+
{
46+
"Author": "Adel",
47+
"Text": "Comment text..",
48+
"Comments": {
49+
"Author": "Moon",
50+
"Text": "Comment text.."
51+
}
52+
}
53+
]
54+
}
55+
],
56+
"@metadata": {
57+
"@collection": "BlogPosts"
58+
}
59+
}
60+
{CODE-BLOCK/}
61+
62+
{PANEL/}
63+
64+
{PANEL: Index hierarchical data}
65+
66+
To index the elements of a hierarchical structure like the one above, use RavenDB's `Recurse` method.
67+
68+
The sample index below shows how to use `Recurse` to traverse the comments in the post thread and index them by their authors.
69+
We can then [query the index](../indexes/indexing-hierarchical-data#query-the-index) for all blog posts that contain comments by specific authors.
70+
71+
{CODE-TABS}
72+
{CODE-TAB:php:AbstractIndexCreationTask indexes_2@Indexes\IndexingHierarchicalData.php /}
73+
{CODE-TAB:php:Operation indexes_3@Indexes\IndexingHierarchicalData.php /}
74+
{CODE-TABS/}
75+
76+
{PANEL/}
77+
78+
{PANEL: Query the index}
79+
80+
The index can be queried for all blog posts that contain comments made by specific authors.
81+
82+
**Query the index using code**:
83+
84+
{CODE-TABS}
85+
{CODE-TAB:php:Query indexes_4@Indexes\IndexingHierarchicalData.php /}
86+
{CODE-TAB:php:documentQuery indexes_5@Indexes\IndexingHierarchicalData.php /}
87+
{CODE-TAB-BLOCK:sql:RQL}
88+
from index "BlogPosts/ByCommentAuthor"
89+
where Authors == "Moon"
90+
{CODE-TAB-BLOCK/}
91+
{CODE-TABS/}
92+
93+
**Query the index using Studio**:
94+
95+
* Query the index from Studio's [List of Indexes](../studio/database/indexes/indexes-list-view#indexes-list-view) view:
96+
97+
!["List of Indexes view"](images/list-of-indexes-view.png "List of Indexes view")
98+
99+
* View the query results in the [Query](../studio/database/queries/query-view) view:
100+
101+
!["Query View"](images/query-view.png "Query view")
102+
103+
* View the list of terms indexed by the `Recurse` method:
104+
105+
!["Click to View Index Terms"](images/click-to-view-terms.png "Click to view index terms")
106+
107+
!["Index Terms"](images/index-terms.png "Index terms")
108+
109+
{PANEL/}
110+
111+
## Related articles
112+
113+
### Indexes
114+
115+
- [Indexing Basics](../indexes/indexing-basics)
116+
- [Indexing Related Documents](../indexes/indexing-related-documents)
117+
- [Indexing Spatial Data](../indexes/indexing-spatial-data)
118+
- [Indexing Polymorphic Data](../indexes/indexing-polymorphic-data)
119+
120+
### Querying
121+
122+
- [Query Overview](../client-api/session/querying/how-to-query)

Documentation/5.4/Raven.Documentation.Pages/indexes/indexing-hierarchical-data.python.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ where Authors == "Moon"
8989
{CODE-TAB-BLOCK/}
9090
{CODE-TABS/}
9191

92-
**Query the index using the Studio**:
92+
**Query the index using Studio**:
9393

94-
* Query the index from the Studio's [List of Indexes](../studio/database/indexes/indexes-list-view#indexes-list-view) view:
94+
* Query the index from Studio's [List of Indexes](../studio/database/indexes/indexes-list-view#indexes-list-view) view:
9595

9696
!["List of Indexes view"](images/list-of-indexes-view.png "List of Indexes view")
9797

0 commit comments

Comments
 (0)