3
3
This is a search engine designed for content sites with simplified yet functional English and Russian morphology support.
4
4
It indexes your content and provides a full-text search.
5
5
6
+ <img src =" doc/rose.svg " >
7
+
6
8
## Requirements
7
9
8
10
1 . PHP 7.4 or later.
@@ -76,45 +78,43 @@ use S2\Rose\Entity\Indexable;
76
78
77
79
// Main parameters
78
80
$indexable = new Indexable(
79
- 'id_1', // External ID - an identifier in your system
80
- 'Test page title', // Title
81
- 'This is the first page to be indexed. I have to make up a content.',
82
- 1 // Instance ID - an optional ID of your subsystem
81
+ 'id_1', // External ID - an identifier in your system
82
+ 'Test page title', // Title
83
+ 'This is the first page to be indexed. I have to make up a content.',
84
+ 1 // Instance ID - an optional ID of your subsystem
83
85
);
84
86
85
87
// Other optional parameters
86
88
$indexable
87
- ->setKeywords('singlekeyword, multiple keywords') // The same as Meta Keywords
88
- ->setDescription('Description can be used in snippets') // The same as Meta Description
89
- ->setDate(new \DateTime('2016-08-24 00:00:00'))
90
- ->setUrl('url1')
91
- ->setRelevanceRatio(3.14) // Multiplier for important pages
89
+ ->setKeywords('singlekeyword, multiple keywords') // The same as Meta Keywords
90
+ ->setDescription('Description can be used in snippets') // The same as Meta Description
91
+ ->setDate(new \DateTime('2016-08-24 00:00:00'))
92
+ ->setUrl('url1')
93
+ ->setRelevanceRatio(3.14) // Multiplier for important pages
92
94
;
93
95
94
96
$indexer->index($indexable);
95
97
96
98
$indexable = new Indexable(
97
- 'id_2',
98
- 'Test page title 2',
99
- 'This is the second page to be indexed. Let\'s compose something new.'
99
+ 'id_2',
100
+ 'Test page title 2',
101
+ 'This is the second page to be indexed. Let\'s compose something new.'
100
102
);
101
103
$indexable->setKeywords('content, page');
102
104
103
105
$indexer->index($indexable);
104
106
```
105
107
106
- The constructor of ` Indexable ` requires 4 arguments:
108
+ The constructor of ` Indexable ` has 4 arguments:
107
109
- external ID - an arbitrary string that is sufficient for your code to identify the page;
108
110
- page title;
109
111
- page content;
110
112
- instance ID - an optional integer ID of the page source (e.g., for multi-site services), as explained below.
111
113
112
114
Optional parameters that you can provide include: keywords, description, date, relevance ratio, and URL.
113
- Keywords are indexed and searched with higher relevance.
114
- The description can be used for building a snippet (see below).
115
- The URL can be an arbitrary string.
116
-
115
+ Keywords are indexed and searched with higher relevance. The description can be used for building a snippet (see below).
117
116
It is suggested to use the content of "keyword" and "description" meta-tags, if available, for this purpose.
117
+ The URL can be an arbitrary string.
118
118
119
119
The ` Indexer::index() ` method is used for both adding and updating the index.
120
120
If the content is unchanged, this method skips the operation. Otherwise, the content is being removed and indexed again.
@@ -138,24 +138,24 @@ $finder = new Finder($storage, $stemmer);
138
138
$resultSet = $finder->find(new Query('content'));
139
139
140
140
foreach ($resultSet->getItems() as $item) {
141
- // first iteration: second iteration:
142
- $item->getId(); // 'id_2' 'id_1'
143
- $item->getInstanceId(); // null 1
144
- $item->getTitle(); // 'Test page title 2' 'Test page title'
145
- $item->getUrl(); // '' 'url1'
146
- $item->getDescription(); // '' 'Description can be used in snippets'
147
- $item->getDate(); // null new \DateTime('2016-08-24 00:00:00')
148
- $item->getRelevance(); // 4.1610856664112195 0.26907154598642522
149
- $item->getSnippet(); // 'This is the second page...' 'I have to make up a <i >content</i >.'
141
+ // first iteration: second iteration:
142
+ $item->getId(); // 'id_2' 'id_1'
143
+ $item->getInstanceId(); // null 1
144
+ $item->getTitle(); // 'Test page title 2' 'Test page title'
145
+ $item->getUrl(); // '' 'url1'
146
+ $item->getDescription(); // '' 'Description can be used in snippets'
147
+ $item->getDate(); // null new \DateTime('2016-08-24 00:00:00')
148
+ $item->getRelevance(); // 4.1610856664112195 0.26907154598642522
149
+ $item->getSnippet(); // 'This is the second page...' 'I have to make up a <i >content</i >.'
150
150
}
151
151
```
152
152
153
153
Modify the ` Query ` object to use a pagination:
154
154
``` php
155
155
$query = new Query('content');
156
156
$query
157
- ->setLimit(10) // 10 results per page
158
- ->setOffset(20) // third page
157
+ ->setLimit(10) // 10 results per page
158
+ ->setOffset(20) // third page
159
159
;
160
160
$resultSet = $finder->find($query);
161
161
@@ -167,9 +167,9 @@ Provide instance id to limit the scope of the search with a subsystem:
167
167
$resultSet = $finder->find((new Query('content'))->setInstanceId(1));
168
168
169
169
foreach ($resultSet->getItems() as $item) {
170
- // first iteration only:
171
- $item->getId(); // 'id_1'
172
- $item->getInstanceId(); // 1
170
+ // first iteration only:
171
+ $item->getId(); // 'id_1'
172
+ $item->getInstanceId(); // 1
173
173
}
174
174
```
175
175
@@ -261,4 +261,4 @@ $similarItems = $readStorage->getSimilar(new ExternalId('id_2'));
261
261
```
262
262
263
263
> [ !NOTE]
264
- > Recommendations are supported on MySQL and PostgreSQL databases, but they are not implemented in SQLite due to limited SQL support.
264
+ > Recommendations are supported on MySQL and PostgreSQL databases. They are not implemented in SQLite due to limited SQL support.
0 commit comments