这是indexloc提供的服务,不要输入任何密码
Skip to content
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
215 changes: 147 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,70 +149,70 @@ This endpoint returns the latest cluster status.
```json
{
"indexer_assignment": {
"example_en": {
"shard-Dyb1CXqJ": "node-YA0Zso3w",
"shard-OSFMC5gL": "node-YA0Zso3w",
"shard-TQu8fyHA": "node-YA0Zso3w",
"shard-UfilJ5I4": "node-YA0Zso3w",
"shard-WLJEezNT": "node-YA0Zso3w",
"shard-eH6LOGpc": "node-YA0Zso3w",
"shard-jWU7v3MR": "node-YA0Zso3w",
"shard-sng0xmKr": "node-YA0Zso3w",
"shard-tKKy1LdN": "node-YA0Zso3w",
"shard-vpI7ExL5": "node-YA0Zso3w"
"wikipedia_en": {
"shard-73iAEf8K": "node-duIMwfjn",
"shard-CRzZVi2b": "node-duIMwfjn",
"shard-Wh7VO5Lp": "node-duIMwfjn",
"shard-YazeIhze": "node-duIMwfjn",
"shard-cXyt4esz": "node-duIMwfjn",
"shard-hUM3HWQW": "node-duIMwfjn",
"shard-jH3sTtc7": "node-duIMwfjn",
"shard-viI2Dm3V": "node-duIMwfjn",
"shard-y1tMwCEP": "node-duIMwfjn",
"shard-y7VRCIlU": "node-duIMwfjn"
}
},
"indexes": {
"example_en": {
"index_lock_uri": "etcd://phalanx/locks/example_en",
"index_uri": "minio://phalanx/indexes/example_en",
"wikipedia_en": {
"index_lock_uri": "",
"index_uri": "file:///tmp/phalanx/indexes/wikipedia_en",
"shards": {
"shard-Dyb1CXqJ": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-Dyb1CXqJ",
"shard_uri": "minio://phalanx/indexes/example_en/shard-Dyb1CXqJ"
"shard-73iAEf8K": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-73iAEf8K"
},
"shard-OSFMC5gL": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-OSFMC5gL",
"shard_uri": "minio://phalanx/indexes/example_en/shard-OSFMC5gL"
"shard-CRzZVi2b": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-CRzZVi2b"
},
"shard-TQu8fyHA": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-TQu8fyHA",
"shard_uri": "minio://phalanx/indexes/example_en/shard-TQu8fyHA"
"shard-Wh7VO5Lp": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-Wh7VO5Lp"
},
"shard-UfilJ5I4": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-UfilJ5I4",
"shard_uri": "minio://phalanx/indexes/example_en/shard-UfilJ5I4"
"shard-YazeIhze": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-YazeIhze"
},
"shard-WLJEezNT": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-WLJEezNT",
"shard_uri": "minio://phalanx/indexes/example_en/shard-WLJEezNT"
"shard-cXyt4esz": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-cXyt4esz"
},
"shard-eH6LOGpc": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-eH6LOGpc",
"shard_uri": "minio://phalanx/indexes/example_en/shard-eH6LOGpc"
"shard-hUM3HWQW": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-hUM3HWQW"
},
"shard-jWU7v3MR": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-jWU7v3MR",
"shard_uri": "minio://phalanx/indexes/example_en/shard-jWU7v3MR"
"shard-jH3sTtc7": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-jH3sTtc7"
},
"shard-sng0xmKr": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-sng0xmKr",
"shard_uri": "minio://phalanx/indexes/example_en/shard-sng0xmKr"
"shard-viI2Dm3V": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-viI2Dm3V"
},
"shard-tKKy1LdN": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-tKKy1LdN",
"shard_uri": "minio://phalanx/indexes/example_en/shard-tKKy1LdN"
"shard-y1tMwCEP": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-y1tMwCEP"
},
"shard-vpI7ExL5": {
"shard_lock_uri": "etcd://phalanx/locks/example_en/shard-vpI7ExL5",
"shard_uri": "minio://phalanx/indexes/example_en/shard-vpI7ExL5"
"shard-y7VRCIlU": {
"shard_lock_uri": "",
"shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-y7VRCIlU"
}
}
}
},
"nodes": {
"node-YA0Zso3w": {
"addr": "172.19.0.4",
"node-duIMwfjn": {
"addr": "0.0.0.0",
"meta": {
"grpc_port": 5000,
"http_port": 8000,
Expand All @@ -221,41 +221,41 @@ This endpoint returns the latest cluster status.
"searcher"
]
},
"port": 2000,
"port": 3000,
"state": "alive"
}
},
"searcher_assignment": {
"example_en": {
"shard-Dyb1CXqJ": [
"node-YA0Zso3w"
"wikipedia_en": {
"shard-73iAEf8K": [
"node-duIMwfjn"
],
"shard-OSFMC5gL": [
"node-YA0Zso3w"
"shard-CRzZVi2b": [
"node-duIMwfjn"
],
"shard-TQu8fyHA": [
"node-YA0Zso3w"
"shard-Wh7VO5Lp": [
"node-duIMwfjn"
],
"shard-UfilJ5I4": [
"node-YA0Zso3w"
"shard-YazeIhze": [
"node-duIMwfjn"
],
"shard-WLJEezNT": [
"node-YA0Zso3w"
"shard-cXyt4esz": [
"node-duIMwfjn"
],
"shard-eH6LOGpc": [
"node-YA0Zso3w"
"shard-hUM3HWQW": [
"node-duIMwfjn"
],
"shard-jWU7v3MR": [
"node-YA0Zso3w"
"shard-jH3sTtc7": [
"node-duIMwfjn"
],
"shard-sng0xmKr": [
"node-YA0Zso3w"
"shard-viI2Dm3V": [
"node-duIMwfjn"
],
"shard-tKKy1LdN": [
"node-YA0Zso3w"
"shard-y1tMwCEP": [
"node-duIMwfjn"
],
"shard-vpI7ExL5": [
"node-YA0Zso3w"
"shard-y7VRCIlU": [
"node-duIMwfjn"
]
}
}
Expand Down Expand Up @@ -283,6 +283,85 @@ This endpoint returns the latest cluster status.
% curl -XPOST -H 'Content-type: text/plain' http://localhost:8000/v1/indexes/wikipedia_en/_search --data-binary @./examples/search.json | jq .
```

```json
{
"documents": [
{
"_id": "1316",
"_score": 4.09425168678948,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1316,
"title": "Annales school"
},
{
"_id": "1164",
"_score": 3.8142450139472404,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1164,
"title": "Artificial intelligence"
},
{
"_id": "1902",
"_score": 3.485971543579737,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1902,
"title": "American Airlines Flight 77"
},
{
"_id": "1397",
"_score": 3.4334036711733162,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1397,
"title": "AOL"
},
{
"_id": "775",
"_score": 3.410320998122167,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 775,
"title": "Algorithm"
},
{
"_id": "1074",
"_score": 3.054015403581521,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1074,
"title": "Royal Antigua and Barbuda Defence Force"
},
{
"_id": "1361",
"_score": 2.8482692170070774,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1361,
"title": "Anagram"
},
{
"_id": "1805",
"_score": 2.783279368389514,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1805,
"title": "Antibiotic"
},
{
"_id": "1924",
"_score": 2.7722489839906252,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1924,
"title": "Argo Navis"
},
{
"_id": "1274",
"_score": 2.7359659717085734,
"_timestamp": "2022-01-02T12:46:13Z",
"id": 1274,
"title": "Geography of Antarctica"
}
],
"hits": 59,
"index_name": "wikipedia_en"
}
```


## Delete index

Expand Down
2 changes: 1 addition & 1 deletion bin/phalanx_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ if [ -p /dev/stdin ]; then
cat -
else
cat ${FILENAME}
fi | jq -c -r '.'${ID_FIELD}' as $id | {"id": $id | tostring, "fields": .}'
fi | jq -c -r '.'${ID_FIELD}' as $id | . |= .+ {"_id": $id | tostring}'
2 changes: 2 additions & 0 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func NewCluster(host string, bindPort int, nodeMetadata NodeMetadata, isSeedNode
// }
// members.UpdateNode(10 * time.Second)

fmt.Println("cluster created", memberList.LocalNode().Name)

return &Cluster{
memberList: memberList,
nodeEventDeliegate: nodeEventDeliegate,
Expand Down
2 changes: 1 addition & 1 deletion cmd/phalanx.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultEnvFile string = ".env"
const defaultConfigFile string = ""

const defaultHost string = "0.0.0.0"
const defaultBindPort int = 3000
const defaultBindPort int = 2000
const defaultGrpcPort int = 5000
const defaultHttpPort int = 8000

Expand Down
3 changes: 2 additions & 1 deletion examples/create_index_example_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,6 @@
}
}
},
"num_shards": 10
"num_shards": 10,
"default_search_field": "_all"
}
3 changes: 2 additions & 1 deletion examples/create_index_wikipedia_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,6 @@
}
}
},
"num_shards": 10
"num_shards": 10,
"default_search_field": "_all"
}
3 changes: 2 additions & 1 deletion examples/create_index_wikipedia_en_local.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@
}
}
},
"num_shards": 10
"num_shards": 10,
"default_search_field": "_all"
}
3 changes: 2 additions & 1 deletion examples/create_index_wikipedia_ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,6 @@
}
}
},
"num_shards": 10
"num_shards": 10,
"default_search_field": "_all"
}
3 changes: 2 additions & 1 deletion examples/create_index_wikipedia_ja_local.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@
}
}
},
"num_shards": 10
"num_shards": 10,
"default_search_field": "_all"
}
9 changes: 6 additions & 3 deletions examples/search.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"index_name": "wikipedia_en",
"query": "search",
"field": "text",
"boost": 1.0,
"start": 0,
"num": 10
"num": 5,
"sort_by": "-_score",
"fields": [
"id",
"title"
]
}
3 changes: 3 additions & 0 deletions index/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/blugelabs/bluge"
"github.com/mosuka/phalanx/directory"
"github.com/mosuka/phalanx/errors"
"github.com/mosuka/phalanx/mapping"
"github.com/mosuka/phalanx/metastore"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -110,6 +111,8 @@ func (i *IndexReaders) open(indexName string, shardName string, indexMetadata *m
}
if indexMetadata.DefaultSearchField != "" {
config.DefaultSearchField = indexMetadata.DefaultSearchField
} else {
config.DefaultSearchField = mapping.AllFieldName
}
// config.DefaultSearchAnalyzer = req.DefaultSearchAnalyzer
// config.DefaultSimilarity = req.DefaultSearchSimilarity
Expand Down
3 changes: 3 additions & 0 deletions index/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/blugelabs/bluge"
"github.com/mosuka/phalanx/directory"
"github.com/mosuka/phalanx/errors"
"github.com/mosuka/phalanx/mapping"
"github.com/mosuka/phalanx/metastore"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -90,6 +91,8 @@ func (i *IndexWriters) open(indexName string, shardName string, indexMetadata *m
}
if indexMetadata.DefaultSearchField != "" {
config.DefaultSearchField = indexMetadata.DefaultSearchField
} else {
config.DefaultSearchField = mapping.AllFieldName
}
// config.DefaultSearchAnalyzer = req.DefaultSearchAnalyzer
// config.DefaultSimilarity = req.DefaultSearchSimilarity
Expand Down
Loading