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

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

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

        <legend id='lVvEm'><style id='lVvEm'><dir id='lVvEm'><q id='lVvEm'></q></dir></style></legend>
      1. 如何在 Lucene 搜索中匹配精確文本?

        How to match exact text in Lucene search?(如何在 Lucene 搜索中匹配精確文本?)
          <tbody id='smh3v'></tbody>
        • <tfoot id='smh3v'></tfoot>

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

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

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

                  本文介紹了如何在 Lucene 搜索中匹配精確文本?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試匹配 TITLE 列中的文本Config migration from ASA5505 8.2 to ASA5516.

                  Im trying to match a text Config migration from ASA5505 8.2 to ASA5516 in column TITLE.

                  我的程序是這樣的.

                  Directory directory = FSDirectory.open(indexDir);
                  
                  MultiFieldQueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_35,new String[] {"TITLE"}, new StandardAnalyzer(Version.LUCENE_35));        
                  IndexReader reader = IndexReader.open(directory);
                  IndexSearcher searcher = new IndexSearcher(reader);       
                  queryParser.setPhraseSlop(0);
                  queryParser.setLowercaseExpandedTerms(true);
                  Query query = queryParser.parse("TITLE:Config migration from ASA5505 8.2 to ASA5516");
                  System.out.println(queryStr);
                  TopDocs topDocs = searcher.search(query,100);
                  System.out.println(topDocs.totalHits);
                  ScoreDoc[] hits = topDocs.scoreDocs;
                  System.out.println(hits.length + " Record(s) Found");
                  for (int i = 0; i < hits.length; i++) {
                      int docId = hits[i].doc;
                      Document d = searcher.doc(docId);
                      System.out.println(""Title :" " +d.get("TITLE") );
                  }
                  

                  但它的回歸

                  "Title :" Config migration from ASA5505 8.2 to ASA5516
                  "Title :" Firewall  migration from ASA5585 to  ASA5555
                  "Title :" Firewall  migration from ASA5585 to  ASA5555
                  

                  第二個 2 結果不是預期的.所以需要什么修改才能匹配確切的文本配置從 ASA5505 8.2 遷移到 ASA5516

                  Second 2 results are not expected.So what modification required to match exact text Config migration from ASA5505 8.2 to ASA5516

                  我的索引函數看起來像這樣

                  And my indexing function looks like this

                  public class Lucene {
                  public static final String INDEX_DIR = "./Lucene";
                  private static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver";
                  private static final String CONNECTION_URL = "jdbc:oracle:thin:xxxxxxx"
                  
                  private static final String USER_NAME = "localhost";
                  private static final String PASSWORD = "localhost";
                  private static final String QUERY = "select * from TITLE_TABLE";
                  
                  public static void main(String[] args) throws Exception {
                      File indexDir = new File(INDEX_DIR);
                      Lucene indexer = new Lucene();
                      try {
                          Date start = new Date();
                          Class.forName(JDBC_DRIVER).newInstance();
                          Connection conn = DriverManager.getConnection(CONNECTION_URL, USER_NAME, PASSWORD);
                          SimpleAnalyzer analyzer = new SimpleAnalyzer(Version.LUCENE_35);
                          IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_35, analyzer);
                          IndexWriter indexWriter = new IndexWriter(FSDirectory.open(indexDir), indexWriterConfig);
                          System.out.println("Indexing to directory '" + indexDir + "'...");
                          int indexedDocumentCount = indexer.indexDocs(indexWriter, conn);
                          indexWriter.close();
                          System.out.println(indexedDocumentCount + " records have been indexed successfully");
                          System.out.println("Total Time:" + (new Date().getTime() - start.getTime()) / (1000));
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
                  
                  int indexDocs(IndexWriter writer, Connection conn) throws Exception {
                      String sql = QUERY;
                      Statement stmt = conn.createStatement();
                      stmt.setFetchSize(100000);
                      ResultSet rs = stmt.executeQuery(sql);
                      int i = 0;
                      while (rs.next()) {
                          System.out.println("Addind Doc No:" + i);
                          Document d = new Document();
                          System.out.println(rs.getString("TITLE"));
                          d.add(new Field("TITLE", rs.getString("TITLE"), Field.Store.YES, Field.Index.ANALYZED));
                          d.add(new Field("NAME", rs.getString("NAME"), Field.Store.YES, Field.Index.ANALYZED));
                          writer.addDocument(d);
                          i++;
                      }
                      return i;
                  }
                  }
                  

                  推薦答案

                  PVR 是正確的,在這里使用短語查詢可能是正確的解決方案,但是他們錯過了如何使用 PhraseQuery 類.不過,您已經在使用 QueryParser,因此只需將搜索文本括在引號中即可使用查詢解析器語法:

                  PVR is correct, that using a phrase query is probably the right solution here, but they missed on how to use the PhraseQuery class. You are already using QueryParser though, so just use the query parser syntax by enclosing you search text in quotes:

                  Query query = queryParser.parse("TITLE:"Config migration from ASA5505 8.2 to ASA5516"");
                  

                  <小時>

                  根據您的更新,您在索引時和查詢時使用了不同的分析器.SimpleAnalyzerStandardAnalyzer 不做同樣的事情.除非您有很好的理由不這樣做,否則您應該在索引和查詢時以相同的方式進行分析.


                  Based on your update, you are using a different analyzer at index-time and query-time. SimpleAnalyzer and StandardAnalyzer don't do the same things. Unless you have a very good reason to do otherwise, you should analyze the same way when indexing and querying.

                  因此,將索引代碼中的分析器更改為 StandardAnalyzer(反之亦然,在查詢時使用 SimpleAnalyzer),您應該會看到更好的結果.

                  So, change the analyzer in your indexing code to StandardAnalyzer (or vice-versa, use SimpleAnalyzer when querying), and you should see better results.

                  這篇關于如何在 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?)

                        <tbody id='a4jkm'></tbody>

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

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

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

                            主站蜘蛛池模板: 日本视频免费观看 | 免费中文字幕日韩欧美 | 香蕉网在线| 在线播放中文字幕 | 成人在线a | 成人免费黄色大片 | 国产又爽又黄免费视频 | 三级网站在线 | 国产在线网站 | 欧美日韩国产三级 | 51免费看成人啪啪片 | 中文字字幕码一二三区 | 青青久草 | 中文一区二区 | 欧美日韩成人在线观看 | 久久99九九 | 97超碰资源 | 日韩精品久久久 | 伊人成人在线 | 高清久久久 | 免费毛片在线 | 黄色片视频网站 | 一区二区自拍 | 91精品国产麻豆国产自产在线 | 一区二区三区国产视频 | 黑人精品一区二区 | 欧美一区二区三区在线视频 | 亚洲丝袜av | 97视频免费在线观看 | 91视频亚洲| 精品一区二区免费视频 | 秋霞一区二区 | 国产超碰在线观看 | 欧美a级成人淫片免费看 | 欧美视频一区二区三区 | 精品一区二区在线视频 | 日本精品免费 | 久久精品视频一区二区 | 亚洲午夜av | 夜夜贪欢〈高h〉 | 亚洲 欧美 日韩 在线 |