<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 查詢重寫機制 <div style="text-indent:2em;"> <p>如果你曾經使用過很多不同的查詢類型,比如前綴查詢和通配符查詢,從本質上上,任何的查詢都可以視為對多個關鍵詞的查詢。可能用戶聽說過查詢重寫(query rewrite),ElasticSearch(實際上是Apache Lucene很明顯地)對用戶的查詢進行了重寫,這樣做是為了保證性能。整個重寫過程是把從Lucene角度認為原始的、開銷大的查詢對象轉變成一系列開銷小的查詢對象的一個過程。</p> <h3 style="text-indent:0em;">以前綴查詢為例</h3> <p>展示查詢重寫內部運作機制的最好方法是通過一個例子,查看例子中用戶輸入的原查詢語句中的term在內部被什么Term所取代。假定我們的索引中有如下的數據:</p> <blockquote> curl&nbsp;&nbsp;-XPUT&nbsp;&nbsp;'localhost:9200/clients/client/1'&nbsp;&nbsp;-d<br/> '{<br/> &nbsp;&nbsp;"id":"1","name":"Joe"<br/> }'<br/> curl&nbsp;&nbsp;-XPUT&nbsp;&nbsp;'localhost:9200/clients/client/2'&nbsp;&nbsp;-d<br/> '{<br/> &nbsp;&nbsp;"id":"2","name":"Jane"<br/> }'<br/> curl&nbsp;&nbsp;-XPUT&nbsp;&nbsp;'localhost:9200/clients/client/3'&nbsp;&nbsp;-d<br/> '{<br/> &nbsp;&nbsp;"id":"3","name":"Jack"<br/> }'<br/> curl&nbsp;&nbsp;-XPUT&nbsp;&nbsp;'localhost:9200/clients/client/4'&nbsp;&nbsp;-d<br/> '{<br/> &nbsp;&nbsp;"id":"4","name":"Rob"<br/> }'<br/> curl&nbsp;&nbsp;-XPUT&nbsp;&nbsp;'localhost:9200/clients/client/5'&nbsp;&nbsp;-d<br/> '{<br/> &nbsp;&nbsp;"id":"5","name":"Jannet"<br/> }'<br/> </blockquote> <br/><!--note structure --> <div style="height:110px;width:650px;text-indent:0em;"> <div style="float:left;width:13px;height:100%; background:black;"> <img src="../lm.png" height="100px" width="13px" style="margin-top:5px;"/> </div> <div style="float:left;width:50px;height:100%;position:relative;"> <img src="../note.png" style="position:absolute; top:30%; "/> </div> <div style="float:left; width:550px;height:100%;"> <b><br/>源碼下載</b> <p style="font-size:13px;">所有購買了Packt出版的圖書的讀者都可以用自己的賬戶從http://www.packtpub.com. 下載源代碼文件。如果讀者通過其它的途徑下載本書,則需要通過http://www.packtpub.com/support 來注冊賬號,然后網站會把源碼通過e-mail發送到你的郵箱。 </p> </div> <div style="float:left;width:13px;height:100%;background:black;"> <img src="../rm.png" height="100px" width="13px" style="margin-top:5px;"/> </div> </div> <!-- end of note structure --> <br/> <p>我們的目的是找到所有以字符 j 開頭的文檔。這個需求非常簡單,在 client索引上運行如下的查詢表達式:</p> <blockquote> curl -XGET 'localhost:9200/clients/_search?pretty' -d '{ <blockquote>"query" : {<blockquote> "prefix" : { <blockquote>"name" : "j",<br/> "rewrite" : "constant_score_boolean"</blockquote> }</blockquote> }</blockquote> }'</blockquote> <p> 我們用的是一個簡單的前綴查詢;前面說過我們的目的是找到符合以下條件的文檔:name域中包含以字符 j 開頭的Term。我們用rewrite參數來指定重寫查詢的方法,關于該參數的取值我們稍后討論。運行前面的查詢命令,我們得到的結果如下:</p> <blockquote style="text-indent:0em;">{ ...<br/> "hits" : {<blockquote> "total" : 4,<br/> "max_score" : 1.0,<br/> "hits" : [ {<blockquote> "_index" : "clients",<br/> "_type" : "client",<br/> "_id" : "5",<br/> "_score" : 1.0, "_source" : {"id":"5","name":"Jannet"}</blockquote> }, {<blockquote> "_index" : "clients",<br/> "_type" : "client",<br/> "_id" : "1",<br/> "_score" : 1.0, "_source" : {"id":"1", "name":"Joe"}</blockquote> }, {<blockquote> "_index" : "clients",<br/> "_type" : "client",<br/> "_id" : "2",<br/> "_score" : 1.0, "_source" : {"id":"2", "name":"Jane"}</blockquote> }, {<blockquote> "_index" : "clients",<br/> "_type" : "client",<br/> "_id" : "3",<br/> "_score" : 1.0, "_source" : {"id":"3", "name":"Jack"}</blockquote> } ]</blockquote> } }</blockquote> </div>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看