久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='ZSX9X'></bdo><ul id='ZSX9X'></ul>

    <i id='ZSX9X'><tr id='ZSX9X'><dt id='ZSX9X'><q id='ZSX9X'><span id='ZSX9X'><b id='ZSX9X'><form id='ZSX9X'><ins id='ZSX9X'></ins><ul id='ZSX9X'></ul><sub id='ZSX9X'></sub></form><legend id='ZSX9X'></legend><bdo id='ZSX9X'><pre id='ZSX9X'><center id='ZSX9X'></center></pre></bdo></b><th id='ZSX9X'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZSX9X'><tfoot id='ZSX9X'></tfoot><dl id='ZSX9X'><fieldset id='ZSX9X'></fieldset></dl></div>

  1. <tfoot id='ZSX9X'></tfoot>
  2. <legend id='ZSX9X'><style id='ZSX9X'><dir id='ZSX9X'><q id='ZSX9X'></q></dir></style></legend>

    <small id='ZSX9X'></small><noframes id='ZSX9X'>

    1. 在elasticsearch中轉義特殊字符

      Escaping special characters in elasticsearch(在elasticsearch中轉義特殊字符)
    2. <small id='AOqSJ'></small><noframes id='AOqSJ'>

        <tbody id='AOqSJ'></tbody>
          • <i id='AOqSJ'><tr id='AOqSJ'><dt id='AOqSJ'><q id='AOqSJ'><span id='AOqSJ'><b id='AOqSJ'><form id='AOqSJ'><ins id='AOqSJ'></ins><ul id='AOqSJ'></ul><sub id='AOqSJ'></sub></form><legend id='AOqSJ'></legend><bdo id='AOqSJ'><pre id='AOqSJ'><center id='AOqSJ'></center></pre></bdo></b><th id='AOqSJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AOqSJ'><tfoot id='AOqSJ'></tfoot><dl id='AOqSJ'><fieldset id='AOqSJ'></fieldset></dl></div>

          • <tfoot id='AOqSJ'></tfoot>
              <bdo id='AOqSJ'></bdo><ul id='AOqSJ'></ul>

                <legend id='AOqSJ'><style id='AOqSJ'><dir id='AOqSJ'><q id='AOqSJ'></q></dir></style></legend>
                本文介紹了在elasticsearch中轉義特殊字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 elasticsearch python 客戶端 對 elasticsearch 實例進行一些查詢我們正在托管.

                I am using the elasticsearch python client to make some queries to the elasticsearch instance that we are hosting.

                我注意到有些字符需要轉義.具體來說,這些...

                I noticed that some characters need to be escaped. Specifically, these...

                + - && || ! ( ) { } [ ] ^ " ~ * ? : 
                

                除了我已經想到的之外,有沒有一種干凈的方法可以做到這一點?當然有比做更清潔的方法

                Is there a clean way to do this beyond what I've already got in mind? Surely there is a cleaner way than doing

                term
                    .replace("+", "+")
                    .replace("-", "-")
                
                    # ....etc
                

                我希望有一個我可以使用的 API 調用,但我在文檔中找不到.這似乎是一個很常見的問題,應該由某人解決.

                I was hoping there was an API call that I could use, but I can't find one in the docs. This seems like a common enough issue that it should have been solved by someone.

                有人知道正確"的做法嗎?

                Does anyone know the "correct" way of doing this?

                我仍然不確定是否有 API 調用,但我得到的東西足夠簡潔,足以讓我滿意.

                EDIT : I am still not sure if there is an API call, but I got things concise enough to where I am happy.

                def needs_escaping(character):                                                                                                                                                                                        
                
                    escape_chars = {                                                                                                                                                                                               
                        '\' : True, '+' : True, '-' : True, '!' : True,                                                                                                                                                           
                        '(' : True, ')' : True, ':' : True, '^' : True,                                                                                                                                                            
                        '[' : True, ']': True, '"' : True, '{' : True,                                                                                                                                                            
                        '}' : True, '~' : True, '*' : True, '?' : True,                                                                                                                                                            
                        '|' : True, '&' : True, '/' : True                                                                                                                                                                         
                    }                                                                                                                                                                                                              
                    return escape_chars.get(character, False)   
                
                
                sanitized = ''
                for character in query:                                                                                                                                                                                            
                
                    if needs_escaping(character):                                                                                                                                                                                 
                        sanitized += '\%s' % character                                                                                                                                                                           
                    else:                                                                                                                                                                                                      
                        sanitized += character 
                

                推薦答案

                是的,您需要在 query_string 查詢.為此(假設您使用的是 PyLucene),您應該能夠使用 QueryParserBase.escape(String).

                Yes, those characters will need to be replaced within content you want to search in a query_string query. To do that (assuming you are using PyLucene), you should be able to use QueryParserBase.escape(String).

                除此之外,您始終可以根據您的需要調整 QueryParserBase.escape 源代碼:

                Barring that, you could always adapt the QueryParserBase.escape source code to your needs:

                public static String escape(String s) {
                  StringBuilder sb = new StringBuilder();
                  for (int i = 0; i < s.length(); i++) {
                    char c = s.charAt(i);
                    // These characters are part of the query syntax and must be escaped
                    if (c == '\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':'
                      || c == '^' || c == '[' || c == ']' || c == '"' || c == '{' || c == '}' || c == '~'
                      || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') {
                      sb.append('\');
                    }
                    sb.append(c);
                  }
                  return sb.toString();
                }
                

                這篇關于在elasticsearch中轉義特殊字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                message.channel.id Discord PY(message.channel.id Discord PY)
                How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

              1. <legend id='cIn40'><style id='cIn40'><dir id='cIn40'><q id='cIn40'></q></dir></style></legend>

                <small id='cIn40'></small><noframes id='cIn40'>

                  • <i id='cIn40'><tr id='cIn40'><dt id='cIn40'><q id='cIn40'><span id='cIn40'><b id='cIn40'><form id='cIn40'><ins id='cIn40'></ins><ul id='cIn40'></ul><sub id='cIn40'></sub></form><legend id='cIn40'></legend><bdo id='cIn40'><pre id='cIn40'><center id='cIn40'></center></pre></bdo></b><th id='cIn40'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cIn40'><tfoot id='cIn40'></tfoot><dl id='cIn40'><fieldset id='cIn40'></fieldset></dl></div>
                      <bdo id='cIn40'></bdo><ul id='cIn40'></ul>

                        <tbody id='cIn40'></tbody>
                        1. <tfoot id='cIn40'></tfoot>
                          主站蜘蛛池模板: 免费在线播放黄色 | 九九成人 | 一级大黄色片 | 欧美一级黄色免费 | 亚洲婷婷六月天 | www.成人久久 | 在线免费av电影 | 日本三级黄视频 | 国产91观看| 91视频精选| 综合国产第二页 | 亚洲精品久久久久久国产精华液 | 高清不卡毛片 | 一区二区在线 | 欧美日韩成人在线 | 欧美在线观看免费观看视频 | 一级片aaa| 欧美一区视频 | 国产日韩欧美精品一区二区三区 | 国产乱码精品一区二区三区五月婷 | 一级免费a | 黄色一级视频 | 一区二区福利视频 | 一区二区精品在线 | 欧美精品一区二区三区在线 | 免费亚洲婷婷 | 亚洲另类自拍 | 成人影院免费视频 | 久久大香| 亚洲综合大片69999 | 天天爽一爽 | 日韩理论电影在线观看 | 成人在线免费视频 | 91精品久久久久久久久中文字幕 | av中文天堂 | 精品国产乱码久久久久久闺蜜 | 日韩精品 电影一区 亚洲 | 日韩高清中文字幕 | 精品一区二区久久久久久久网精 | 欧美video | 九九热九九 |