2016-12-23 1 views
0

私はfake index per userに行っていますが、私のユーザーIDは電子メールです。私のエイリアスに@があると、検索は空です。例えばelasticsearchエイリアシングの禁止文字はありますか?

、私はmy_alias検索が正常に動作していると、私の@ LIASはありませんが、以下のように一つの指標my_indexと2別名my_alias[email protected]を作成する場合:

curl -XPUT 'elasticsearch:9200/my_index' 
{"acknowledged":true} 

curl -XPUT 'elasticsearch:9200/my_index/_alias/my_alias -d '{"routing": "my_alias", "filter": {"term": {"doc_id": "my_alias"}}}' 
{"acknowledged":true} 

curl -XPUT 'elasticsearch:9200/my_index/_alias/[email protected]' -d '{"routing": "[email protected]", "filter": {"term": {"doc_id": "[email protected]"}}}' 
{"acknowledged":true} 

curl -XPUT 'elasticsearch:9200/my_alias/doc/1' -d '{doc_id:"my_alias", title: "hello world"}' 
{"_index":"my_index","_type":"doc","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true} 

curl -XPUT 'elasticsearch:9200/[email protected]/doc/2' -d '{doc_id:"[email protected]", title: "hello dude"}' 
{"_index":"my_index","_type":"doc","_id":"2","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true} 

curl -XGET 'elasticsearch:9200/my_alias/doc/_search?pretty=true' -d'{"query": {"match": {"title": "hello"}}}' 
{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
     "total" : 1, 
     "successful" : 1, 
     "failed" : 0 
    }, 
    "hits" : { 
     "total" : 1, 
     "max_score" : 0.19178301, 
     "hits" : [ { 
      "_index" : "my_index", 
      "_type" : "doc", 
      "_id" : "1", 
      "_score" : 0.19178301, 
      "_routing" : "my_alias", 
      "_source" : { 
       "doc_id" : "my_alias", 
       "title" : "hello world" 
      } 
     } ] 
    } 
} 

curl -XGET 'elasticsearch:9200/[email protected]/doc/_search?pretty=true' -d'{"query": {"match": {"title": "hello"}}}' 
{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
     "total" : 1, 
     "successful" : 1, 
     "failed" : 0 
    }, 
    "hits" : { 
     "total" : 0, 
     "max_score" : null, 
     "hits" : [ ] 
    } 
} 

何を私に困惑することは一切Invalid Alias Name Exceptionがないことです検索結果はOKですが空です。

URLエンコード%40elasticsearch:9200/my%40liasでも試しましたが同じです。

インデックス全体を検索すると、2つのドキュメントが表示されます。 @でインデックスを作成すると、インデックスの検索も正常です。私がESの状態を見るために_aliasesをカールすると、私はそれを見ることができます:

"my_index" : { 
    "aliases" : { 
    "[email protected]" : { 
     "filter" : { 
     "term" : { 
      "doc_id" : "[email protected]" 
     } 
     }, 
     "index_routing" : "[email protected]", 
     "search_routing" : "[email protected]" 
    }, 
    "my_alias" : { 
     "filter" : { 
     "term" : { 
      "doc_id" : "my_alias" 
     } 
     }, 
     "index_routing" : "my_alias", 
     "search_routing" : "my_alias" 
    } 
    } 
}, 

あなたはその動作の何らかの理由がありますか?私は何かが恋しいですか?

答えて

0

は、あなたは、単にこのようなURLエンコード@署名する必要があり:

curl -XGET 'elasticsearch:9200/my%40lias/doc/_search?pretty=true' 
           ^
            | 
          change this 
+0

oups、私はうーん、それはとしなければならないかもしれません –

+0

ポストを編集していますルーティングを使用している方法。 – Val

+0

でも、それはまさに上記のリンクと同じで、1つではなく他のものと一緒に働いています... –

0

が、私は私の地元では、あなたのインデックスを再現し、私はあなたが持っている問題は、あなたが正しくドキュメントをインデックスしていないということだと思います。例えば

、この要求を見てみましょう:

curl -XPUT 'elasticsearch:9200/my_alias/doc/1' -d '{doc_id:"my_alias", title: "hello world"}' 

それは

curl -XPUT "http://localhost:9200/my_alias/doc/1" -d' 
{"doc_id":"my_alias", "title": "hello world"}' 

でなければなりません{DOC_IDの違いに注意してください: "my_alias"{ "DOC_IDを" : "my_alias"、には、doc_idの引用符がありません。これはタイトルにも適用されます。

完全固定例:私はこれを試したことに言及しているはずですが、それはどちらかのURLエンコードの問題ではありません

PUT /my_index 
PUT /my_index/_alias/my_alias 
{"routing": "my_alias", "filter": {"term": {"doc_id": "my_alias"}}} 

PUT /my_index/_alias/[email protected] 
{"routing": "[email protected]", "filter": {"term": {"doc_id": "[email protected]"}}} 

PUT /my_alias/doc/1 
{ 
    "doc_id":"my_alias", "title": "hello world" 

} 

PUT /[email protected]/doc/2 
{ 
    "doc_id": "[email protected]", 
    "title": "hello dude" 
} 


GET /my_alias/doc/_search?pretty=true 
{ 
    "query": { 
    "match": { 
     "title": "hello" 
    } 
    } 
} 

{ 
    "took": 2, 
    "timed_out": false, 
    "_shards": { 
    "total": 1, 
    "successful": 1, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 1, 
    "max_score": 0.19178301, 
    "hits": [ 
     { 
     "_index": "my_index", 
     "_type": "doc", 
     "_id": "1", 
     "_score": 0.19178301, 
     "_routing": "my_alias", 
     "_source": { 
      "doc_id": "my_alias", 
      "title": "hello world" 
     } 
     } 
    ] 
    } 
} 
+0

はまったく固定されていません。質問を読んでください:my_aliasで2つのケースがあります。私のものとは別のものです。私は二重引用符を忘れてしまったという事実に基づいて最初の例が動作していることをどう説明しますか? –

関連する問題