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

  • <small id='ItzHn'></small><noframes id='ItzHn'>

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

        • <bdo id='ItzHn'></bdo><ul id='ItzHn'></ul>
        <legend id='ItzHn'><style id='ItzHn'><dir id='ItzHn'><q id='ItzHn'></q></dir></style></legend>

        使用 Lucene 統計分類結果

        Using Lucene to count results in categories(使用 Lucene 統計分類結果)
        • <small id='y2u6I'></small><noframes id='y2u6I'>

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

                  <tfoot id='y2u6I'></tfoot>
                    <tbody id='y2u6I'></tbody>
                  本文介紹了使用 Lucene 統計分類結果的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試使用 Lucene Java 2.3.2 來實現對產品目錄的搜索.除了產品的常規字段外,還有一個名為類別"的字段.一個產品可以屬于多個類別.目前,我使用 FilteredQuery 在每個類別中搜索相同的搜索詞,以獲取每個類別的結果數.

                  I am trying to use Lucene Java 2.3.2 to implement search on a catalog of products. Apart from the regular fields for a product, there is field called 'Category'. A product can fall in multiple categories. Currently, I use FilteredQuery to search for the same search term with every Category to get the number of results per category.

                  這會導致每個查詢進行 20-30 次內部搜索調用以顯示結果.這大大減慢了搜索速度.有沒有更快的方法使用 Lucene 實現相同的結果?

                  This results in 20-30 internal search calls per query to display the results. This is slowing down the search considerably. Is there a faster way of achieving the same result using Lucene?

                  推薦答案

                  這就是我所做的,雖然它有點占用內存:

                  Here's what I did, though it's a bit heavy on memory:

                  你需要的是提前創建一堆 BitSets,每個類別一個,包含一個類別中所有文檔的doc id.現在,在搜索時,您使用 HitCollector 并對照 BitSet 檢查文檔 ID.

                  What you need is to create in advance a bunch of BitSets, one for each category, containing the doc id of all the documents in a category. Now, on search time you use a HitCollector and check the doc ids against the BitSets.

                  以下是創建位集的代碼:

                  Here's the code to create the bit sets:

                  public BitSet[] getBitSets(IndexSearcher indexSearcher, 
                                             Category[] categories) {
                      BitSet[] bitSets = new BitSet[categories.length];
                      for(int i=0; i<categories.length; i++)
                      {
                          Query query = categories[i].getQuery();
                          final BitSet bitset = new BitSet()
                          indexSearcher.search(query, new HitCollector() {
                              public void collect(int doc, float score) {
                                  bitSet.set(doc);
                              }
                          });
                          bitSets[i] = bitSet;
                      }
                      return bitSets;
                  }
                  

                  這只是一種方法.您可能會使用 TermDocs 如果您的類別足夠簡單,則不要運行完整搜索,但無論如何,這應該只在您加載索引時運行一次.

                  This is just one way to do this. You could probably use TermDocs instead of running a full search if your categories are simple enough, but this should only run once when you load the index anyway.

                  現在,當需要計算搜索結果的類別時,您可以這樣做:

                  Now, when it's time to count categories of search results you do this:

                  public int[] getCategroryCount(IndexSearcher indexSearcher, 
                                                 Query query, 
                                                 final BitSet[] bitSets) {
                      final int[] count = new int[bitSets.length];
                      indexSearcher.search(query, new HitCollector() {
                          public void collect(int doc, float score) {
                              for(int i=0; i<bitSets.length; i++) {
                                  if(bitSets[i].get(doc)) count[i]++;
                              }
                          }
                      });
                      return count;
                  }
                  

                  最終得到的是一個數組,其中包含搜索結果中每個類別的計數.如果您還需要搜索結果,則應將 TopDocCollector 添加到您的命中收集器(yo dawg ...).或者,您可以再次運行搜索.2 次搜索優于 30 次.

                  What you end up with is an array containing the count of every category within the search results. If you also need the search results, you should add a TopDocCollector to your hit collector (yo dawg...). Or, you could just run the search again. 2 searches are better than 30.

                  這篇關于使用 Lucene 統計分類結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)
                  <legend id='K8PTs'><style id='K8PTs'><dir id='K8PTs'><q id='K8PTs'></q></dir></style></legend>
                1. <tfoot id='K8PTs'></tfoot>

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

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

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

                            <tbody id='K8PTs'></tbody>
                            主站蜘蛛池模板: 欧美日韩专区 | 欧美性生活一区二区三区 | 国产高清一区二区三区 | 在线播放中文字幕 | 欧美一级淫片007 | 欧洲免费视频 | 国产成人精品一区二区三 | 中文字幕第5页 | 在线观看免费av网 | 亚洲成人在线视频播放 | 99视频在线免费观看 | 国产一区二区精品在线 | 久操福利| 国产成人网 | 国产精品久久福利 | 亚洲人在线 | 人人人人爽 | 97视频人人澡人人爽 | 亚洲vs天堂 | 91麻豆产精品久久久久久夏晴子 | 中文字幕国产高清 | 久久尤物免费一区二区三区 | 国产精品久久久久久久久久久久冷 | 欧美黄色网 | www.日韩| 日韩欧美精品一区 | 久久久九九 | 国产精品久久福利 | 国产精品视频网 | 国产精品九九九 | 日本人麻豆 | 亚洲成av| 黄色免费观看网站 | 国产中文字幕网 | 国产视频中文字幕 | 99精品视频一区二区三区 | 99精品国产一区二区三区 | 亚洲一一在线 | 国久久 | 国产一级电影网 | 久久精品国产一区二区三区不卡 |