Skip to content

Commit 447246d

Browse files
committed
Updated readme.
1 parent d00e67d commit 447246d

File tree

2 files changed

+41
-32
lines changed

2 files changed

+41
-32
lines changed

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This is a search engine designed for content sites with simplified yet functional English and Russian morphology support.
44
It indexes your content and provides a full-text search.
55

6+
<img src="doc/rose.svg">
7+
68
## Requirements
79

810
1. PHP 7.4 or later.
@@ -76,45 +78,43 @@ use S2\Rose\Entity\Indexable;
7678

7779
// Main parameters
7880
$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
8385
);
8486

8587
// Other optional parameters
8688
$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
9294
;
9395

9496
$indexer->index($indexable);
9597

9698
$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.'
100102
);
101103
$indexable->setKeywords('content, page');
102104

103105
$indexer->index($indexable);
104106
```
105107

106-
The constructor of `Indexable` requires 4 arguments:
108+
The constructor of `Indexable` has 4 arguments:
107109
- external ID - an arbitrary string that is sufficient for your code to identify the page;
108110
- page title;
109111
- page content;
110112
- instance ID - an optional integer ID of the page source (e.g., for multi-site services), as explained below.
111113

112114
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).
117116
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.
118118

119119
The `Indexer::index()` method is used for both adding and updating the index.
120120
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);
138138
$resultSet = $finder->find(new Query('content'));
139139

140140
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>.'
150150
}
151151
```
152152

153153
Modify the `Query` object to use a pagination:
154154
```php
155155
$query = new Query('content');
156156
$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
159159
;
160160
$resultSet = $finder->find($query);
161161

@@ -167,9 +167,9 @@ Provide instance id to limit the scope of the search with a subsystem:
167167
$resultSet = $finder->find((new Query('content'))->setInstanceId(1));
168168

169169
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
173173
}
174174
```
175175

@@ -261,4 +261,4 @@ $similarItems = $readStorage->getSimilar(new ExternalId('id_2'));
261261
```
262262

263263
> [!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.

doc/rose.svg

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)