Lucene中的各种Query实例

Lucene硬核解析专题系列(三):查询解析与执行 Lucene的查询解析与执行是一个从文本到结果的精密过程。将用户输入转化为结构化查询,多种查询类型满足复杂需求,BM25评分模型确保结果相关性,高效执行搜索。下一篇文章将探讨性能优化与调优,揭示Lucene在高负载场景下的应对策略。 阅读详情

(1):TernQuery

/*
 * Created on 2006-3-11
 
*/

package ch11;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;

public class TermQueryTest
{
  
public static void main(String[] args) throws Exception
  
{
    Document doc1 
= new Document();
    doc1.add(Field.Text(
"name", "word1 word2 word3"));
    doc1.add(Field.Keyword(
"title", "doc1"));

    IndexWriter writer 
= new IndexWriter("c:/java/index", new StandardAnalyzer(), true);
    writer.addDocument(doc1);
    writer.close();

    Query query 
= null;
    Hits hits 
= null;
    
    IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
    
    query 
= new TermQuery(new Term("name","word1"));
    hits 
= searcher.search(query);
    printResult(hits, 
"word1");
    
    query 
= new TermQuery(new Term("title","doc1"));
    hits 
= searcher.search(query);
    printResult(hits, 
"doc1");

  }


  
public static void printResult(Hits hits, String key) throws Exception
  
{
    System.out.println(
"查找 "" + key + "" :");
    
if (hits != null)
    
{
      
if (hits.length() == 0)
      
{
        System.out.println(
"没有找到任何结果");
      }

      
else
      
{
        System.out.println(
"找到" + hits.length() + "个结果");
        
for (int i = 0; i < hits.length(); i++)
        
{
          Document d 
= hits.doc(i);
          String dname 
= d.get("title");
          System.out.print(dname 
+ "   ");
        }

        System.out.println();
        System.out.println();
      }

    }

  }

}


运行结果:
C:/>java TermQueryTest
查找 "word1" :
找到1个结果
doc1

查找 "doc1" :
找到1个结果
doc1

(2):与或搜索

 

/*
 * Created on 2006-3-11
 
*/

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;

public class BooleanQueryTest1
{
  
public static void main (String [] args) throws Exception {
    Document doc1 
= new Document();
    doc1.add(Field.Text(
"name", "word1 word2 word3"));
    doc1.add(Field.Keyword(
"title", "doc1"));
    
    Document doc2 
= new Document();
    doc2.add(Field.Text(
"name", "word1 word4 word5"));
    doc2.add(Field.Keyword(
"title", "doc2"));
    
    Document doc3 
= new Document();
    doc3.add(Field.Text(
"name", "word1 word2 word6"));
    doc3.add(Field.Keyword(
"title", "doc3"));
    
    IndexWriter writer 
= new IndexWriter("c:/java/index", new StandardAnalyzer(), true);
    writer.addDocument(doc1);
    writer.addDocument(doc2);
    writer.addDocument(doc3);
    writer.close();
    
    Query query1 
= null;
    Query query2 
= null;
    BooleanQuery query 
= null;
    Hits hits 
= null;
    
    IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
    
    query1 
= new TermQuery(new Term("name","word1"));
    query2 
= new TermQuery(new Term("name","word2"));
    
    
// 构造一个布尔查询
    query = new BooleanQuery();

  
// 添加两个子查询,与关系
  
//  query.add(query1, true, false);
 
//  query.add(query2, true, false);
    
    
    
// 添加两个子查询,或关系
    query.add(query1, false, false);
    query.add(query2, 
false, false);
    
    hits 
= searcher.search(query);
    printResult(hits, 
"word1和word2");
    
  }

  
  
public static void printResult(Hits hits, String key) throws Exception
  
{
    System.out.println(
"查找 "" + key + "" :");
    
if (hits != null)
    
{
      
if (hits.length() == 0)
      
{
        System.out.println(
"没有找到任何结果");
      }

      
else
      
{
        System.out.println(
"找到" + hits.length() + "个结果");
        
for (int i = 0; i < hits.length(); i++)
        
{
          Document d 
= hits.doc(i);
          String dname 
= d.get("title");
          System.out.print(dname 
+ "   ");
        }

        System.out.println();
        System.out.println();
      }

    }

  }

}

运行结果:

C:/>java BooleanQueryTest1
查找 "word1和word2" :
找到3个结果
doc1 doc3 doc2
 

(3):在范围内搜索

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.RangeQuery;

public class RangeQueryTest {
    
public static void main (String [] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"time", "200001"));
        doc1.add(Field.Keyword(
"title", "doc1"));
        
        Document doc2 
= new Document();
        doc2.add(Field.Text(
"time", "200002"));
        doc2.add(Field.Keyword(
"title", "doc2"));
        
        Document doc3 
= new Document();
        doc3.add(Field.Text(
"time", "200003"));
        doc3.add(Field.Keyword(
"title", "doc3"));
        
        Document doc4 
= new Document();
        doc4.add(Field.Text(
"time", "200004"));
        doc4.add(Field.Keyword(
"title", "doc4"));
        
        Document doc5 
= new Document();
        doc5.add(Field.Text(
"time", "200005"));
        doc5.add(Field.Keyword(
"title", "doc5"));
        
        IndexWriter writer 
= new IndexWriter("c:/java/index", new StandardAnalyzer(), true);
        writer.setUseCompoundFile(
true);
        writer.addDocument(doc1);
        writer.addDocument(doc2);
        writer.addDocument(doc3);
        writer.addDocument(doc4);
        writer.addDocument(doc5);
        writer.close();
        
        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term beginTime 
= new Term("time","200001");
        Term endTime 
= new Term("time","200005");
        
        Hits hits 
= null;
        RangeQuery query 
= null;
        
        query 
= new RangeQuery(beginTime, endTime, false);
        hits 
= searcher.search(query);
        printResult(hits, 
"从200001到200005的文档,不包括200001和200005");
        
        query 
= new RangeQuery(beginTime, endTime, true);
        hits 
= searcher.search(query);
        printResult(hits, 
"从200001到200005的文档,包括200001和200005");
        
    }

    
    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   " );
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}


运行结果:
C:/java>java   RangeQueryTest
查找 "从200001到200005的文档,不包括200001和200005" :
找到doc2   doc3   doc4

查找 "从200001到200005的文档,包括200001和200005" :
找到doc1 doc2 doc3 doc4 doc5

(4):使用前缀搜索

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.RangeQuery;

public class PrefixQueryTest {
    
public static void main(String[] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"name", "David"));
        doc1.add(Field.Keyword(
"title", "doc1"));

        Document doc2 
= new Document();
        doc2.add(Field.Text(
"name", "Darwen"));
        doc2.add(Field.Keyword(
"title", "doc2"));

        Document doc3 
= new Document();
        doc3.add(Field.Text(
"name", "Smith"));
        doc3.add(Field.Keyword(
"title", "doc3"));

        Document doc4 
= new Document();
        doc4.add(Field.Text(
"name", "Smart"));
        doc4.add(Field.Keyword(
"title", "doc4"));

        IndexWriter writer 
= new IndexWriter("c:/java/index",
                
new StandardAnalyzer(), true);
        writer.setUseCompoundFile(
true);
        writer.addDocument(doc1);
        writer.addDocument(doc2);
        writer.addDocument(doc3);
        writer.addDocument(doc4);
        writer.close();

        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term pre1 
= new Term("name", "Da");
        Term pre2 
= new Term("name", "da");
        Term pre3 
= new Term("name", "sm");

        Hits hits 
= null;
        PrefixQuery query 
= null;

        query 
= new PrefixQuery(pre1);
        hits 
= searcher.search(query);
        printResult(hits, 
"前缀为'Da'的文档");
        
        query 
= new PrefixQuery(pre2);
        hits 
= searcher.search(query);
        printResult(hits, 
"前缀为'da'的文档");
        
        query 
= new PrefixQuery(pre3);
        hits 
= searcher.search(query);
        printResult(hits, 
"前缀为'sm'的文档");

    }


    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
                System.out.println();
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   ");
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}

C:/>java  PrefixQueryTest
查找 "前缀为'Da'的文档" :
没有找到任何结果

查找 "前缀为'da'的文档" :
找到doc1 doc2

查找 "前缀为'sm'的文档" :
找到doc3 doc4

注:Lucene的标准分析器在进行分词过滤时将所有的关键字一律转成了小写,所以有上述结果。

(5):多关键字搜索

 

package ch11;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.PrefixQuery;

public class PhraseQueryTest {
    
public static void main(String[] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"content", "david mary smith robert"));
        doc1.add(Field.Keyword(
"title", "doc1"));

        IndexWriter writer 
= new IndexWriter("c:/java/index",
                
new StandardAnalyzer(), true);
        writer.setUseCompoundFile(
true);
        writer.addDocument(doc1);
        writer.close();

        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term word1 
= new Term("content", "david");
        Term word2 
= new Term("content","mary");
        Term word3 
= new Term("content","smith");
        Term word4 
= new Term("content","robert");
        
        Hits hits 
= null;
        PhraseQuery query 
= null;

        
// 第一种情况,两个词本身紧密相连,先设置坡度为0,再设置坡度为2
        query = new PhraseQuery();
        query.add(word1);
        query.add(word2);
        query.setSlop(
0);
        hits 
= searcher.search(query);
        printResult(hits, 
"'david'与'mary'紧紧相隔的Document");
        
        query.setSlop(
2);
        hits 
= searcher.search(query);
        printResult(hits, 
"'david'与'mary'中相隔两个词的短语");
        
        
// 第二种情况,两个词本身相隔两个词,先设置坡度为0,再设置坡度为2
        query = new PhraseQuery();
        query.add(word1);
        query.add(word4);
        query.setSlop(
0);
        hits 
= searcher.search(query);
        printResult(hits, 
"'david'与'robert'紧紧相隔的Document");
        
        query.setSlop(
2);
        hits 
= searcher.search(query);
        printResult(hits, 
"'david'与'robert'中相隔两个词的短语");
        

    }


    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
                System.out.println();
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   ");
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}

运行结果:
C:/java>java  PrefixQueryTest
查找 "前缀为'Da'的文档" :
没有找到任何结果

查找 "前缀为'da'的文档" :
找到doc1 doc2

查找 "前缀为'sm'的文档" :
找到doc3 doc4

注:对两个紧连的关键字,无论将坡度设置为多少,Lucene总能找到它所在的文档,而对不紧连的关键字,如果坡度值小于它们之间无关词的数量,那么则无法找到。

(6):短语搜索

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhrasePrefixQuery;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.RangeQuery;

public class PhrasePrefixQueryTest {
    
public static void main(String[] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"content", "david mary smith robert"));
        doc1.add(Field.Keyword(
"title", "doc1"));

        IndexWriter writer 
= new IndexWriter("c:/java/index",
                
new StandardAnalyzer(), true);
        writer.addDocument(doc1);
        writer.close();

        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term word1 
= new Term("content", "david");
        Term word2 
= new Term("content", "mary");
        Term word3 
= new Term("content", "smith");
        Term word4 
= new Term("content", "robert");

        Hits hits 
= null;
        PhrasePrefixQuery query 
= null;
        
        query 
= new PhrasePrefixQuery();
        
// 加入可能的所有不确定的词
        query.add(new Term[]{word1, word2});
        
// 加入确定的词
        query.add(word4);
        query.setSlop(
2);
        hits 
= searcher.search(query);
        printResult(hits, 
"存在短语'david robert'或'mary robert'的文档");
        
        
    }


    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
                System.out.println();
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   ");
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}


运行结果:
C:/>java  PhrasePrefixQueryTest
查找 "存在短语'david robert'或'mary robert'的文档" :
找到doc1

(7):相近词搜索

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;

public class FuzzyQueryTest {
    
public static void main(String[] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"content", "david"));
        doc1.add(Field.Keyword(
"title", "doc1"));

        Document doc2 
= new Document();
        doc2.add(Field.Text(
"content", "sdavid"));
        doc2.add(Field.Keyword(
"title", "doc2"));

        Document doc3 
= new Document();
        doc3.add(Field.Text(
"content", "davie"));
        doc3.add(Field.Keyword(
"title", "doc3"));

        IndexWriter writer 
= new IndexWriter("c:/java/index",
                
new StandardAnalyzer(), true);
        writer.addDocument(doc1);
        writer.addDocument(doc2);
        writer.addDocument(doc3);
        writer.close();

        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term word1 
= new Term("content", "david");

        Hits hits 
= null;
        FuzzyQuery query 
= null;

        query 
= new FuzzyQuery(word1);
        hits 
= searcher.search(query);
        printResult(hits,
"与'david'相似的词");
    }


    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
                System.out.println();
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   ");
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}

(8):通配符搜索

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.WildcardQuery;

public class WildcardQueryTest {
    
public static void main(String[] args) throws Exception {
        Document doc1 
= new Document();
        doc1.add(Field.Text(
"content", "whatever"));
        doc1.add(Field.Keyword(
"title", "doc1"));
        
        Document doc2 
= new Document();
        doc2.add(Field.Text(
"content", "whoever"));
        doc2.add(Field.Keyword(
"title", "doc2"));
        
        Document doc3 
= new Document();
        doc3.add(Field.Text(
"content", "however"));
        doc3.add(Field.Keyword(
"title", "doc3"));
        
        Document doc4 
= new Document();
        doc4.add(Field.Text(
"content", "everest"));
        doc4.add(Field.Keyword(
"title", "doc4"));
        
        IndexWriter writer 
= new IndexWriter("c:/java/index",
                
new StandardAnalyzer(), true);
        writer.addDocument(doc1);
        writer.addDocument(doc2);
        writer.addDocument(doc3);
        writer.addDocument(doc4);
        writer.close();

        IndexSearcher searcher 
= new IndexSearcher("c:/java/index");
        Term word1 
= new Term("content", "*ever");
        Term word2 
= new Term("content", "wh?ever");
        Term word3 
= new Term("content", "h??ever");
        Term word4 
= new Term("content", "ever*");
        WildcardQuery query 
= null;
        Hits hits 
= null;
        
        query 
= new WildcardQuery(word1);
        hits 
= searcher.search(query);
        printResult(hits, 
"*ever");
        
        query 
= new WildcardQuery(word2);
        hits 
= searcher.search(query);
        printResult(hits, 
"wh?ever");
        
        query 
= new WildcardQuery(word3);
        hits 
= searcher.search(query);
        printResult(hits, 
"h??ever");
        
        query 
= new WildcardQuery(word4);
        hits 
= searcher.search(query);
        printResult(hits, 
"ever*");
    }

    
    
public static void printResult(Hits hits, String key) throws Exception {
        System.out.println(
"查找 "" + key + "" :");
        
if (hits != null) {
            
if (hits.length() == 0) {
                System.out.println(
"没有找到任何结果");
                System.out.println();
            }
 else {
                System.out.print(
"找到");
                
for (int i = 0; i < hits.length(); i++) {
                    Document d 
= hits.doc(i);
                    String dname 
= d.get("title");
                    System.out.print(dname 
+ "   ");
                }

                System.out.println();
                System.out.println();
            }

        }

    }

}

运行结果:
C:/>java   WildcardQueryTest
查找 "*ever" :
找到doc1   doc2   doc3

查找 "wh?ever" :
找到doc2

查找 "h??ever" :
找到doc3

查找 "ever*" :
找到doc4

【Elasticsearch系列】5分钟掌握查询原理-lucece查询逻辑介绍 通过本篇文章,应该可以对lucene的查询过程有了大概的了解,但其实对于elasticsearch的慢查询分析还远远不够,因为像布尔查询,wilcard之类的比较复杂的查询,我们还得弄懂,它们底层是究竟如何把一个大查询分解成小查询的。才能更好的弄懂查询耗时的原因,所以在下一节,我会讲解这些比较常见的查询类型的内部重写和查询逻辑。 阅读详情

相关推荐

Lucene中各种Query的用法与场景分析

Lucene中各种Query的用法与场景分析 1.背景介绍 在现代信息时代,数据已经成为了企业和个人的重要资产。随着数据量的不断增长,有效地检索和利用这些数据变得至关重要。Apache Lucene是一个高性能、全功能的搜索引擎库,它提供了强大的索引和搜索功能,可以帮助我们快速地

AI大模型应用之禅 1111

Lucene查询语法详解

Lucene提供了丰富的API来组合定制你所需要的查询器,同时也可以利用 Query Parser提供的强大的查询语法解析来构造你想要的查询器。本文章详细的介绍了Lucene的查询语法。通过Java语法分析器把一个查询字符串解析成 Lucene的查询器。在你选择使用Query Parser前,请考虑以下事项:如果你打算在程序中拼接查询语法串然后再利用Query Parser转换,那么强烈建议你利用...

zfsn7722483的专栏 1320

CMU的local_planner学习笔记

ros::Subscriber subOdometry = nh.subscribe//当接收到/state_estimation话题消息更新时启动odometryHandler回调函数 (消息格式:nav_msgs::Odometry消息内容:关于机器人或车辆的位置和方向(姿态)信息)pcl::PointCloud::Ptr freePaths(new pcl::PointCloud());

qq_35971623的博客 3882

使用 Apache Lucene 搜索文本

481

OpenCV图像去畸变实战指南:从原理到参数调优(附完整代码与效果对比)

本文深入解析了OpenCV图像去畸变的原理与实战技巧,详细对比了标准透视、鱼眼及全能型omnidir三种校正函数的核心参数调优方法。通过分析alpha、balance、centerX/Y及focalScale四大参数对输出效果的影响,并结合完整代码与效果对比图,帮助开发者精准校正镜头畸变,提升计算机视觉任务精度。

weixin_29046611的博客 341

Docker拉取ubuntu22.04镜像使用ROS2 humble及仿真工具可视化进行导航

Docker中安装Ubun22以及ROS,gazebo可视化等

lovebc的博客 1678

理解Lucene中的Query

Query是一个接口,它有很多实现类。 QueryParser是Query解析器,用于将一个字符串解析为一个Query对象,这个Query对象可能属于TermQuery,也可能属于PhraseQuery、TermQuery、BooleanQuery等。可以通过Query对象的getClass()方法来查看这个对象到底是哪个实现类。 Lucene已经给我们提供了很多Query查询器,如Ph...

539

Qt 插件开发 plugin 超详细 有源码

Qt 插件化开发框架类似于前后端的微服务的场景,授权哪个微服务则前端可以使用哪个微服务,插件就行硬件插卡一样,可以被随时删除、插入和修改,所以结构很灵活,容易修改,方便软件的升级和维护;插件主要面向接口编程,无需访问.lib文件,热插拔、利于团队开发。即使在程序运行时.dll不存在,也可以正常启动,只是相应插件功能无法正常使用而已;动态库需要访问.lib文件,而且在程序运行时必须保证.lib存在,否则无法正常启动;

q610098308的专栏 6548

基于lucene的案例开发:Query查询

在Lucene索引的搜索过程中,构建Query对象是一个十分重要的过程,在这篇博客中,我们将重点介绍几种常用的Query子类:QueryParser、MultiFieldQueryParser、TermQuery、PrefixQuery、PhraseQuery、WildcardQuery、TermRangeQuery、NumericRangeQuery、BooleanQuery

小鸡慢慢的专栏 4806

CMOS的宽/长比、传输门与三态门、锁存器与触发器、简单版图、竞争与冒险

目录 1.CMOS的宽长比 2.传输门与三态门 传输门 三态门 3.锁存器与触发器 3.1RS锁存器[3] 3.2D锁存器 3.3D触发器 4.简单CMOS器件的版图 5.竞争与冒险 1.CMOS的宽长比 关于COMS原理及结构图可以参考[1]COMS原理及门电路设计. 栅在源漏方向的长度称作栅的长L,垂直方向称为栅的宽W,如图1中NMOS的版图。 图1 以MOS管...

king阿金 1万+

使用TBtools进行物种间共线性分析

Sequence Toolkit ---Fasta Tools ----ID Prefix (fasta文件)

sunny_dayone的博客 8755

lucene query

建立索引后,给定一个查询词,可以进行搜索,官网有个建索引和搜索的小demo: Analyzer analyzer = new StandardAnalyzer(); // Store the index in memory: Directory directory = new RAMDirectory(); // To store an index on disk, use this in

fxnfk 558

【TCAD】AlGaN 器件的Sentaurus仿真

否则,必须在 LatticeParameters Sentaurus Device 的参数文件中的部分。Sentaurus Device 有两个工具实例:第一个工具实例, sd_fdiv ,模拟正向偏置特性,第二个工具实例, sd_rviv ,模拟反向偏置特性直至击穿。对于牛顿求解器,通常应该将非线性迭代次数限制为一个足够小的值,例如 Iterations=20 ,同时通过指定非阻尼迭代次数高于允许的牛顿迭代次数来避免解的阻尼( NotDamped=30 )。晶胞中的 Ga-N 键为橙色。

荷塘阅色 1215

Lucene中的 Query对象

检索前,需要对检索字符串进行分析,这是由QueryParser来完成的。为了保证查询的正确性,最好用创建索引文件时同样的分析器。QueryParser解析字符串时,可以指定查询域,实际可以在字符串中指定一个或多个域。例如:“Info:电视台 AND ID:3329”,“Info:电视台”,“电视台”,假如不指定默认域,就会在默认域查询。Que...

banpai3782的博客 137

ShaderJoy —— 简单又神奇的 “合体” 函数【GLSL】

smin 函数 它实际上有两种常见的实现方式 多项式 指数 多项式 smin 函数图 其对应的代码为 float smin( float a, float b ) { // 多项式 const float k = 0.5; float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0); return mix(b, a, h) - k * h * (1.0 - h); } 从上图中我们可以很明显的看出有两处不连...

ShaderJoy 的兴趣技术杂货铺 1858

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

全面解剖 Solr query 到lucene query

全面解剖 Solr query 到lucene query (2013-03-26 14:46:41) 转载▼ 标签: 杂谈 分类: 搜索技术 围绕从顶之下,从粗到西的关系认识solr 查询流程和实现细节。最低下定位到queryparse的实现。整个过程围绕信息检索这一思路展开,而不是工程实现来看这个问题。目的从整体结构上认识查询这一块的抽象。这样有具体需求的时候,...

lusic01的专栏 409

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

支持打印Lucene5数字域Query

Lucene5 在打印数字Query时 Query.toString是不支持的 只会打印出类信息, 所以在原源基础上做了修改可打印数据域。 代码如下: package searcher; import java.util.HashSet; import java.util.Set; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.sea

qqwwssaagg的博客 208

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Lucene搜索流程(4.Query)

最进由于工作的事和国庆,回家了没有环境来写文章,所以搁置了好久,人一懒就不想动,其中有人催我,想想也不能半途而废了,由于之前也写了些草稿,决心今天一定要写了这玩意。闲话不多说,开始介绍Lucene的查询。 如果将整个Lucene系统当做一个数据库系统也勉强说得过去,因为它拥有完善的存储系...

chiqind612229的博客 249

Lucene Query

Query:public abstract class Query implements java.io.Serializable, Cloneable public class PhraseQuery extends Query {@link TermQuery} {@link MultiTermQuery} {@link BooleanQuery} ...

我的生活 196

lucene-查询query->QueryParser

对于搜索引擎(比如Google和百度)来讲,很多情况下只需要用户在输入框内输入所需查询的内容,然后再单击“搜索”就可以了,其余的事情全部交给搜索引擎去处理,最后搜索引擎会把检索到的结果显示出来。那么搜索引擎是怎样处理用户输入得符号串的呢? 在Lucene中,这项工作就交给了QueryParser类来完成,它的作用就是把各种用户输入的符号串转为一个内部的Query或者一个Query组。虽...

269

lucene源码分析(6)Query分析

查询的入口 /** Lower-level search API. * * <p>{@link LeafCollector#collect(int)} is called for every matching document. * * @throws BooleanQuery.TooManyClauses If a query wo...

237

lucene的query

检索前,需要对检索字符串进行分析,这是由QueryParser来完成的。为了保证查询的正确性,最好用创建索引文件时同样的分析器。QueryParser解析字符串时,可以指定查询域,实际可以在字符串中指定一个或多个域。例如:“Info:电视台 AND ID:3329”,“Info:电视台”,“电视台”,假如不指定默认域,就会在默认域查询。   QueryParser调用静态方法Parse后会返回

1295
上一篇: Tomcat公用连接池
下一篇: Oracle中的大字段 Blob/Clob
nobody_java
博客等级 码龄20年 2粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值