adjust document (#14)
* Update search_document.md * Update search_document.md * Update search_document.md * Update search_document.md * Update search_document.md * Update use_and_access_seasearch_apis.md * Update search_document.md Update unified search descriptions. * Update use_and_access_seasearch_apis.md * Update index_management.md * Update index_management.md * Update index_management.md --------- Co-authored-by: Jiaqiang Xu <xjqkilling@gmail.com>
This commit is contained in:
parent
d525d8b5d8
commit
1124ee6c3f
3 changed files with 48 additions and 24 deletions
|
@ -27,6 +27,12 @@ ElasticSearch Mappings Explanation: [Mapping Types](https://www.elastic.co/guide
|
|||
### Configure Settings
|
||||
Index settings control the properties of the index. The most commonly used property is `analysis`, which allows you to customize the analyzers for the index. The analyzers defined here can be used by fields in the mappings.
|
||||
|
||||
SeaSearch does not support replicas and shards since it uses shared storage architecture. Users can only configure analyzers in the settings, so it does not support parameters like these:
|
||||
- number_of_shards
|
||||
- number_of_replicas
|
||||
- other ElasticSearch index settings...
|
||||
|
||||
|
||||
ElasticSearch Settings API: [Update Settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html)
|
||||
|
||||
ElasticSearch related explanation:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
## Search Documents
|
||||
### Query DSL
|
||||
To perform full-text search, use the DSL. For usage, refer to:
|
||||
|
||||
### Basic Search
|
||||
|
||||
You have to use DSL to perform search. For usage, refer to:
|
||||
|
||||
[Query DSL Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)
|
||||
|
||||
|
@ -9,20 +11,41 @@ We do not support all query parameter options provided by ES. Unsupported parame
|
|||
Search API: [Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html)
|
||||
|
||||
### Delete by Query
|
||||
|
||||
To delete documents based on a query, use the delete-by-query operation. Like search, we do not support some ES parameters.
|
||||
|
||||
ElasticSearch API: [Delete by Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html)
|
||||
|
||||
### Multi-Search
|
||||
|
||||
Multi-search supports searching multiple indexes and running different queries on each index.
|
||||
|
||||
ElasticSearch API: [Multi-Search API Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html)
|
||||
|
||||
We extended the multi-search to support using the same scoring information across different indexes for more accurate score calculation. To enable this, set `unify_score=true` in the query.
|
||||
|
||||
`unify_score` is meaningful only in this scenario: when searching the same query across multiple indexes. For example, in Seafile, we create an index for each library. When globally searching across all accessible libraries, enabling unify_score ensures consistent scoring across different repositories, providing more accurate search results.
|
||||
```
|
||||
[POST] /es/_msearch?unify_score=true
|
||||
[POST] /es/_msearch
|
||||
{"index": "t1"}
|
||||
{"query": {"bool": {"should": [{"match": {"filename": {"query": "数据库", "minimum_should_match": "-25%"}}}, {"match": {"filename.ngram": {"query": "数据库", "minimum_should_match": "80
|
||||
```
|
||||
|
||||
### Unified Search
|
||||
|
||||
When you search multiple indexes with the same query, the "/es/_search" and "/es/_msearch" APIs will calculate scores for each indexes separately. This means you cannot simply sort the results from multiple indexes by relevance. This is inconvenient in some use cases. For example, in Seafile, we create an index for each library. When we search a query for all accessible libraries, it's necesary to sort all results from all libraries based on unified scores.
|
||||
|
||||
To support such scenarios, we provide a unified search API. Please note that the query for each index should be the same except for [filters](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html#filter-context).
|
||||
|
||||
```
|
||||
[POST] /api/unified_search
|
||||
{
|
||||
"index_queries": [
|
||||
{
|
||||
"index": "index1",
|
||||
"query": {}
|
||||
},
|
||||
{
|
||||
"index": "index2",
|
||||
"query": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
@ -117,16 +117,17 @@ You can create an index by **PUT `/Index_name`** with related settings, for exma
|
|||
|
||||
```sh
|
||||
curl -X 'POST' \
|
||||
'https://seasearch.example.com/api/index' \
|
||||
'https://seasearch.example.com/es/index_1' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cnVfdXNlcm5hbWU6cnVfcGFzc3dvcmQ=' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"name": "index_1",
|
||||
"settings": {
|
||||
"number_of_shards": 3,
|
||||
"number_of_replicas": 2
|
||||
}
|
||||
-d '{
|
||||
"mappings:{
|
||||
"name":{
|
||||
"type":"text",
|
||||
"highlightable":true
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
|
@ -142,11 +143,11 @@ Example response if index `index_1` creates successfully
|
|||
|
||||
### Create a document
|
||||
|
||||
You can create a document by sending a **POST** request to `/api/<your index name>/_doc`. For example, we add a book names *Snow Crash* by the author *Neal Stephenson*:
|
||||
You can create a document by sending a **POST** request to `/es/<your index name>/_doc`. For example, we add a book names *Snow Crash* by the author *Neal Stephenson*:
|
||||
|
||||
```sh
|
||||
curl -X 'POST' \
|
||||
'https://seasearch.example.com/api/index_1/_doc' \
|
||||
'https://seasearch.example.com/es/index_1/_doc' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cnVfdXNlcm5hbWU6cnVfcGFzc3dvcmQ=' \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
@ -181,7 +182,7 @@ When you have stored a considerable number of documents in an index in SeaSearch
|
|||
|
||||
```sh
|
||||
curl -X 'POST' \
|
||||
'https://seasearch.example.com/api/index_1/_search' \
|
||||
'https://seasearch.example.com/es/index_1/_search' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cnVfdXNlcm5hbWU6cnVfcGFzc3dvcmQ=' \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
@ -199,13 +200,7 @@ The response lists up to 10 records matching the query results:
|
|||
```json
|
||||
{
|
||||
"took": 1,
|
||||
"timed_out": false,
|
||||
"_shards": {
|
||||
"total": 3,
|
||||
"successful": 3,
|
||||
"skipped": 0,
|
||||
"failed": 0
|
||||
},
|
||||
"timed_out": false,
|
||||
"hits": {
|
||||
"total": {
|
||||
"value": 1
|
||||
|
@ -235,7 +230,7 @@ You can delete a document by **DELETE** `/api/<your index name>/_doc/<your docum
|
|||
|
||||
```sh
|
||||
curl -X 'DELETE' \
|
||||
'https://seasearch.example.com/api/index_1/_doc/2evSk96OVLa' \
|
||||
'https://seasearch.example.com/es/index_1/_doc/2evSk96OVLa' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cnVfdXNlcm5hbWU6cnVfcGFzc3dvcmQ='
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue