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

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

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

      1. <small id='ytgup'></small><noframes id='ytgup'>

        如何在 Lucene QueryParser 中指定兩個字段?

        How to specify two Fields in Lucene QueryParser?(如何在 Lucene QueryParser 中指定兩個字段?)
            <bdo id='2NkRv'></bdo><ul id='2NkRv'></ul>
              <tfoot id='2NkRv'></tfoot>
            1. <small id='2NkRv'></small><noframes id='2NkRv'>

              1. <legend id='2NkRv'><style id='2NkRv'><dir id='2NkRv'><q id='2NkRv'></q></dir></style></legend>
                • <i id='2NkRv'><tr id='2NkRv'><dt id='2NkRv'><q id='2NkRv'><span id='2NkRv'><b id='2NkRv'><form id='2NkRv'><ins id='2NkRv'></ins><ul id='2NkRv'></ul><sub id='2NkRv'></sub></form><legend id='2NkRv'></legend><bdo id='2NkRv'><pre id='2NkRv'><center id='2NkRv'></center></pre></bdo></b><th id='2NkRv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2NkRv'><tfoot id='2NkRv'></tfoot><dl id='2NkRv'><fieldset id='2NkRv'></fieldset></dl></div>
                    <tbody id='2NkRv'></tbody>
                • 本文介紹了如何在 Lucene QueryParser 中指定兩個字段?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我閱讀了 如何在 QueryParser 中合并多個字段? 但我沒聽懂.

                  I read How to incorporate multiple fields in QueryParser? but i didn't get it.

                  目前我有一個非常奇怪的結構,例如:

                  At the moment i have a very strange construction like:

                  parser = New QueryParser("bodytext", analyzer)
                  parser2 = New QueryParser("title", analyzer)
                  query = parser.Parse(strSuchbegriff)
                  query2 = parser.Parse(strSuchbegriff)
                  

                  我能做些什么:

                  parser = New QuerParser ("bodytext" , "title",analyzer)
                  query =parser.Parse(strSuchbegriff) 
                  

                  因此解析器會在bodytext"字段和title"字段中查找搜索詞.

                  so the Parser looks for the searching word in the field "bodytext" an in the field "title".

                  推薦答案

                  有 3 種方法可以做到這一點.

                  There are 3 ways to do this.

                  第一種方式是手動構造查詢,這就是QueryParser在內部做的.這是最有效的方法,這意味著如果您想阻止訪問 QueryParser 的一些更奇特的功能,則不必解析用戶輸入:

                  The first way is to construct a query manually, this is what QueryParser is doing internally. This is the most powerful way to do it, and means that you don't have to parse the user input if you want to prevent access to some of the more exotic features of QueryParser:

                  IndexReader reader = IndexReader.Open("<lucene dir>");
                  Searcher searcher = new IndexSearcher(reader);
                  
                  BooleanQuery booleanQuery = new BooleanQuery();
                  Query query1 = new TermQuery(new Term("bodytext", "<text>"));
                  Query query2 = new TermQuery(new Term("title", "<text>"));
                  booleanQuery.add(query1, BooleanClause.Occur.SHOULD);
                  booleanQuery.add(query2, BooleanClause.Occur.SHOULD);
                  // Use BooleanClause.Occur.MUST instead of BooleanClause.Occur.SHOULD
                  // for AND queries
                  Hits hits = searcher.Search(booleanQuery);
                  

                  第二種方法是使用MultiFieldQueryParser,它的行為類似于QueryParser,允許訪問它擁有的所有功能,除了它會搜索多個字段.

                  The second way is to use MultiFieldQueryParser, this behaves like QueryParser, allowing access to all the power that it has, except that it will search over multiple fields.

                  IndexReader reader = IndexReader.Open("<lucene dir>");
                  Searcher searcher = new IndexSearcher(reader);
                  
                  Analyzer analyzer = new StandardAnalyzer();
                  MultiFieldQueryParser queryParser = new MultiFieldQueryParser(
                                                          new string[] {"bodytext", "title"},
                                                          analyzer);
                  
                  Hits hits = searcher.Search(queryParser.parse("<text>"));
                  

                  最后一種方式是使用QueryParser的特殊語法看這里.

                  The final way is to use the special syntax of QueryParser see here.

                  IndexReader reader = IndexReader.Open("<lucene dir>");
                  Searcher searcher = new IndexSearcher(reader);    
                  
                  Analyzer analyzer = new StandardAnalyzer();
                  QueryParser queryParser = new QueryParser("<default field>", analyzer);
                  // <default field> is the field that QueryParser will search if you don't 
                  // prefix it with a field.
                  string special = "bodytext:" + text + " OR title:" + text;
                  
                  Hits hits = searcher.Search(queryParser.parse(special));
                  

                  您的另一種選擇是在索引內容時創建一個名為 bodytextandtitle 的新字段,您可以將 bodytext 和標題的內容放入其中,然后您只需搜索一個字段.

                  Your other option is to create new field when you index your content called bodytextandtitle, into which you can place the contents of both bodytext and title, then you only have to search one field.

                  這篇關于如何在 Lucene QueryParser 中指定兩個字段?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                    <bdo id='qeTsp'></bdo><ul id='qeTsp'></ul>
                      <tbody id='qeTsp'></tbody>
                    • <i id='qeTsp'><tr id='qeTsp'><dt id='qeTsp'><q id='qeTsp'><span id='qeTsp'><b id='qeTsp'><form id='qeTsp'><ins id='qeTsp'></ins><ul id='qeTsp'></ul><sub id='qeTsp'></sub></form><legend id='qeTsp'></legend><bdo id='qeTsp'><pre id='qeTsp'><center id='qeTsp'></center></pre></bdo></b><th id='qeTsp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qeTsp'><tfoot id='qeTsp'></tfoot><dl id='qeTsp'><fieldset id='qeTsp'></fieldset></dl></div>
                      <tfoot id='qeTsp'></tfoot>

                      1. <small id='qeTsp'></small><noframes id='qeTsp'>

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

                            主站蜘蛛池模板: 欧美日韩专区 | 欧美在线不卡 | 久久精品亚洲精品国产欧美 | 久久一区 | 欧美成人一区二区三区 | 日本久久久影视 | 久久亚洲精品国产精品紫薇 | 欧美四虎| 欧美激情一区二区三级高清视频 | 精品久久一区 | 999re5这里只有精品 | 中文字幕在线不卡播放 | a黄视频| 欧美福利视频 | 自拍第1页 | 久久小视频 | 99亚洲精品| 五月婷婷丁香婷婷 | 激情视频一区 | 美日韩视频| 亚洲精品一区二区三区中文字幕 | www97影院| 在线永久看片免费的视频 | 亚洲第1页| 精品国产乱码久久久久久老虎 | 色吧色综合| 噜噜噜噜狠狠狠7777视频 | 欧美日韩国产一区二区三区 | 日本网站在线看 | 国产精久久久久久久妇剪断 | 精品国产不卡一区二区三区 | 亚洲欧美久久 | yiren22综合网成人 | 粉嫩av| 欧美精品一区二区三区在线播放 | 欧美日韩一二区 | 亚洲欧美一区二区三区在线 | 国产大学生情侣呻吟视频 | 国产在线永久免费 | 国产综合在线视频 | 婷婷狠狠|