Все дело в используемом вами анализаторе. StandardAnalyzer
делает некоторые сложные вещи с пунктирными именами в попытке «сделать то, что вы имеете в виду». Возможно, WhitespaceAnalyzer
будет лучше соответствовать вашим потребностям.
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);
}