Lucene分析仪和dots

Lucene分析仪和dots,lucene,lucene.net,Lucene,Lucene.net,我是Lucene的新手 有没有办法让Lucene analyzer不忽略字符串中的点?? 例如,如果我的搜索条件是:“A.B.C.D”,Lucene应该只给我搜索结果中包含“A.B.C.D”而不是“ABCD”的文档。…这都是关于您使用的分析器的。这个词用虚线表示,试图“照你的意思去做”。也许这将是一个更好的匹配您的需要 public static void main(String[] args) throws Exception { RAMDirectory dir = new RAMD

我是Lucene的新手

有没有办法让Lucene analyzer不忽略字符串中的点??
例如,如果我的搜索条件是:“A.B.C.D”,Lucene应该只给我搜索结果中包含“A.B.C.D”而不是“ABCD”的文档。…

这都是关于您使用的分析器的。这个词用虚线表示,试图“照你的意思去做”。也许这将是一个更好的匹配您的需要

public static void main(String[] args) throws Exception {
    RAMDirectory dir = new RAMDirectory();
    IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    doc.add(new Field("text", "A.B.C.D DEF", Field.Store.YES, Field.Index.ANALYZED));
    iw.addDocument(doc);
    iw.close();

    IndexSearcher searcher = new IndexSearcher(dir);
    QueryParser queryParser = new QueryParser("text", new WhitespaceAnalyzer());

    // prints 0 
    System.out.println(searcher.search(queryParser.parse("ABCD"), 1).totalHits);

    // prints 1
    System.out.println(searcher.search(queryParser.parse("A.B.C.D"), 1).totalHits);
}

这都是关于你使用的分析仪。这个词用虚线表示,试图“照你的意思去做”。也许这将是一个更好的匹配您的需要

public static void main(String[] args) throws Exception {
    RAMDirectory dir = new RAMDirectory();
    IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    doc.add(new Field("text", "A.B.C.D DEF", Field.Store.YES, Field.Index.ANALYZED));
    iw.addDocument(doc);
    iw.close();

    IndexSearcher searcher = new IndexSearcher(dir);
    QueryParser queryParser = new QueryParser("text", new WhitespaceAnalyzer());

    // prints 0 
    System.out.println(searcher.search(queryParser.parse("ABCD"), 1).totalHits);

    // prints 1
    System.out.println(searcher.search(queryParser.parse("A.B.C.D"), 1).totalHits);
}

您好,谢谢…使用whitespaceanalyzer,我如何向lucene输入停止词?基本上,您必须编写一个新的分析器,这并不难。如果你想了解更多细节,我建议你提出一个新问题。嗨,谢谢……使用whitespaceanalyzer,我如何向lucene输入停止词?基本上,你必须编写一个新的分析器,这并不难。如果你想了解更多细节,我建议你提出一个新问题。