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

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

  • <tfoot id='tYyes'></tfoot>

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

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

        在 Lucene 5.0 中按字母順序排序字符串字段

        Sortiing String field alphabetically in Lucene 5.0(在 Lucene 5.0 中按字母順序排序字符串字段)

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

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

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

                1. 本文介紹了在 Lucene 5.0 中按字母順序排序字符串字段的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在 Lucene 5.0 中對字符串字段進行排序時遇到問題.顯然,自 Lucene 4 以來您可以進行排序的方式已經改變.下面顯示了一些正在為我的文檔編制索引的字段的片段.

                  I'm having issues sorting on string fields in Lucene 5.0. Apparantly the way you could sort since Lucene 4 has changed. Below shows a snippet of some of the fields that are being index for my documents.

                  @Override
                  public Document generateDocument(Process entity)
                  {
                      Document doc = new Document();
                      doc.add(new IntField(id, entity.getID(), Field.Store.YES));
                      doc.add(new TextField(title, entity.getProcessName(), Field.Store.YES));
                      doc.add(new IntField(organizationID, entity.getOrganizationID(), Field.Store.YES));
                      doc.add(new StringField(versionDate, DateTools.dateToString(entity.getVersionDate(), DateTools.Resolution.SECOND), Field.Store.YES));
                      doc.add(new LongField(entityDate, entity.getVersionDate().getTime(), Field.Store.YES)); 
                      return doc;
                  }
                  

                  我想先對相關性進行排序,這很好用.我遇到的問題是標題字段上的排序不起作用.我創建了一個排序字段,我試圖在一系列方法調用之后與 TopFieldCollector 一起使用.

                  I would like to sort on relevance first, which works just fine. The issue I have is that sorting on the title field doesn't work. I've created a sortfield which i'm trying to use with a TopFieldCollector after a chain of method calls.

                  public BaseSearchCore<Process, ProcessSearchResultScore>.SearchContainer search(String searchQuery, Filter filter, int page, int hitsPerPage) throws IOException, ParseException
                      {
                      SortField titleSort = new SortField(title, SortField.Type.STRING, true);
                      return super.search(searchQuery, filter, page, hitsPerPage, title);
                      }
                  

                  去往:

                  public SearchContainer search(String searchQuery, Filter filter, int page, int hitsPerPage, SortField... sortfields) throws IOException, ParseException 
                      {
                          Query query = getQuery(searchQuery);
                          TopFieldCollector paginate = getCollector(sortfields);
                          int startIndex = (page -1) * hitsPerPage;
                          ScoreDoc[] hits = executeSearch(query, paginate, filter, startIndex, hitsPerPage);
                  
                          return collectResults(query, filter, hitsPerPage, hits, page);
                    }
                  

                  最后是應用排序字段的方法:

                  And finally to the method that applies the sort field:

                  private TopFieldCollector getCollector(SortField sortfield) throws IOException
                      {
                          SortField[] sortFields = new SortField[] {SortField.FIELD_SCORE, sortField};
                          Sort sorter = new Sort(sortFields);
                          TopFieldCollector collector = TopFieldCollector.create(sorter, 25000, true, false, true);
                          return collector;
                      }
                  

                  使用返回的收集器執行常規查詢,并返回結果.但是,如果我嘗試使用這個 SortField 進行排序,我會得到這個異常:

                  Using the returned collector a regular query is performed, and a result is returned. However, if I try to sort with this SortField i'll get this exception:

                  java.lang.IllegalStateException:字段標題"的意外文檔值類型 NONE(預期 = SORTED).使用 UninvertingReader 或 index with docvalues.

                  java.lang.IllegalStateException: unexpected docvalues type NONE for field 'title' (expected=SORTED). Use UninvertingReader or index with docvalues.

                  我應該如何索引一個字符串字段以便能夠在 Lucene 5 中按字母順序(使用排序字段)對其進行排序?任何代碼示例或片段都會非常有用.

                  How am I supposed to index a string field to be able to sort it alphabetically(using sortfields) in Lucene 5? Any code examples or snippets would be much appriciated.

                  按相關性搜索效果很好,但是當用戶輸入空搜索查詢時,所有結果都具有相同的相關性.對于這些查詢,我寧愿按結果標題排序,這會在這次 Lucene 迭代中引起問題.

                  Searching by relevancy works just fine, but when users enter empty search queries all the results have the same relevancy. With those queries I'd rather sort by the results titles, which is causing issues in this iteration of Lucene.

                  推薦答案

                  注意:如果您嘗試將其歸結為最小的錯誤,則更容易找出錯誤(對于您自己和您所詢問的人)你可以先舉個例子.與其對您的體系結構和我無權訪問或不了解的類等進行分類,我將解決以下問題:

                  A note: It's way easier to figure out bugs (both for yourself and for the people you're asking) if you try to boil it down to the smallest example that you can first. Rather than sort through your architecture, and classes I don't have access to or know anything about, and such, I'll be addressing the problem as reproduced by this:

                  Sort sort = new Sort(new SortField("title", SortField.Type.STRING));
                  TopDocs docs = searcher.search(new TermQuery(new Term("title", "something")), 10, sort);
                  

                  title 的定義類似于:

                  Where title is defined something like:

                  doc.add(new TextField("title", term, Field.Store.YES));
                  

                  這里對字段進行排序的最佳方法可能是采納關于 docvalues 的建議.將 DocValues 添加到字段本質上是對其進行索引以進行排序,據我了解,它比 Lucene 4.X 中的典型排序方法更有效.將典型的 TextFieldSortedDocValuesField 添加到同一個字段(名稱)似乎效果很好,并且支持使用相同的字段名稱進行搜索和排序:

                  The best approach to sorting fields here is probably going to be to take the advice on docvalues. Adding DocValues to the field is essentially indexing it for sorting, and is much more efficient the typical sorting method in Lucene 4.X, as I understand it. Adding both the typical TextField and the SortedDocValuesField to the same field (name) seems to work rather well, and supports both searching and sorting with the same field name:

                  doc.add(new TextField("title", term, Field.Store.YES));
                  doc.add(new SortedDocValuesField("title", new BytesRef(term)));
                  

                  這篇關于在 Lucene 5.0 中按字母順序排序字符串字段的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)

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

                        <legend id='1fDFQ'><style id='1fDFQ'><dir id='1fDFQ'><q id='1fDFQ'></q></dir></style></legend>
                        • <small id='1fDFQ'></small><noframes id='1fDFQ'>

                            主站蜘蛛池模板: 日韩福利在线 | 欧美色偷偷 | 97精品国产 | 艳妇诱春(第5部分)(h) | 四虎色| 日本xxxx69| 国产精品手机在线观看 | 亚洲在线观看视频 | 国产又爽又黄免费视频 | 人人澡人人爽 | 亚洲一区二区三区在线 | 激情五月综合色婷婷一区二区 | 欧美日韩亚洲国产 | 欧美日韩国产在线 | 丝袜美腿一区二区三区 | 国产精品成人免费精品自在线观看 | 国产精品成人一区二区三区 | 亚洲最大黄色网址 | 国产精品爽爽爽 | 在线黄色av| www.日韩在线 | 国产深夜福利 | 99视频在线观看免费 | 黄色一区二区三区 | 我要看一级黄色片 | 日韩视频在线播放 | 亚洲国产精品久久久久久久 | 简单av网 | 天天爽天天爽 | 欧美日韩综合在线 | 成人免费看片视频 | 国产二区精品 | 激情五月激情综合网 | 天堂免费av | 日日夜夜狠狠 | 久久久久久久成人 | 免费成人结看片 | 黄色网免费 | 日韩理论视频 | 一级片国产 | 日韩一二三 |