Package org.apache.lucene.analysis.standard

Examples of org.apache.lucene.analysis.standard.StandardAnalyzer


  @Transactional(type = TransactionalType.READOLNY)
  public List<Song> search(String condition,String artistCityId) {
    try {
      BooleanQuery booleanQuery = new BooleanQuery();
      MultiFieldQueryParser parser = new MultiFieldQueryParser(
          new String[] { "name", "lyric" }, new StandardAnalyzer());
      Query query;
      query = parser.parse(condition);
      booleanQuery.add(query, BooleanClause.Occur.MUST);
      if(artistCityId != null){
        TermQuery tq = new TermQuery(new Term("artistCityId", artistCityId));
View Full Code Here


          String encoded_message = encodeHtml(message_buf.toString());

          if (highlighter != null)
          {
            TokenStream tokenStream = new StandardAnalyzer().tokenStream("message", new StringReader(encoded_message));
            String highlighted = highlighter.getBestFragments(tokenStream, encoded_message, 25, "...");

            if (!highlighted.equals(""))
            {
              encoded_message = highlighted;
View Full Code Here

        }
    }

    public Hits getOverview( NewsGroup group ) throws IOException, ParseException {
        IndexSearcher searcher = new IndexSearcher( articleOverviewDirectory );
        Query query = QueryParser.parse( group.getName(), "newsgroup", new StandardAnalyzer());
        Hits hits = searcher.search( query );
        return hits;
    }
View Full Code Here

      Assert.notNull(clazz);
      Assert.hasText(query);
        try {
            FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
            List<String> indexedFields = getAllIndexedFields(clazz, "");
            MultiFieldQueryParser parser = new MultiFieldQueryParser(indexedFields.toArray(new String[indexedFields.size()]), new StandardAnalyzer());
            FullTextQuery hq = fullTextEntityManager.createFullTextQuery(parser.parse(query.trim().replaceAll(" ", "* ") + "*"), clazz);
            hq.setMaxResults(number > 0 ? number : MAX_RESULTS);
            hq.setFirstResult(offset > 0 ? offset : 0);
            return hq.getResultList();
        } catch (Exception ex) {
View Full Code Here

 
 
  Directory srcDir = FSDirectory.open(srcIdx);
  Directory targetDir = FSDirectory.open(targetIndx);
  int timesReplicatePerSeg = numReps/numsegs;
  IndexWriter writer = new IndexWriter(targetDir,new StandardAnalyzer(Version.LUCENE_CURRENT),MaxFieldLength.UNLIMITED);
  writer.setMaxMergeDocs(Integer.MAX_VALUE);
  writer.setMergeFactor(Integer.MAX_VALUE);
 
  System.out.println("num segments: "+numsegs);
  System.out.println("num reps per segment: "+timesReplicatePerSeg);
  for (int i=0;i<numsegs;++i){
    RAMDirectory ramDir = new RAMDirectory();
    IndexWriter subWriter = new IndexWriter(ramDir,new StandardAnalyzer(Version.LUCENE_CURRENT),MaxFieldLength.UNLIMITED);
    Directory[] multiplier = new Directory[timesReplicatePerSeg];
    for (int k=0;k<timesReplicatePerSeg;++k){
      multiplier[k]=new RAMDirectory(srcDir);
    }
    subWriter.addIndexesNoOptimize(multiplier);
View Full Code Here

    BrowseRequestBPO.Request req = (BrowseRequestBPO.Request) BrowseProtobufConverter.convert(boboReqBefore);
//    System.out.println("request after conversion to msg:\n" + req.toString());
    String reqString = TextFormat.printToString(req);
    reqString = reqString.replace('\r', ' ').replace('\n', ' ');
//    System.out.println(reqString);
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
    QueryParser _qparser = new QueryParser(Version.LUCENE_CURRENT,"", analyzer);
//    System.out.println("msg to req");
    BrowseRequest boboReqAfter = BrowseProtobufConverter.convert(req, _qparser);
//    System.out.println("get query 2: "
//        + (boboReqAfter.getQuery() != null ? boboReqAfter.getQuery().getClass()
View Full Code Here

  }
 
  static void doBrowse(BoboBrowser browser) throws Exception
  {
    String q="java";
    QueryParser parser=new QueryParser(Version.LUCENE_CURRENT,"b",new StandardAnalyzer(Version.LUCENE_CURRENT));
    Query query=parser.parse(q);
    BrowseRequest br=new BrowseRequest();
    //br.setQuery(query);
    br.setOffset(0);
    br.setCount(0);
View Full Code Here

  }
 
  public void testQueryWithScore() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setShowExplanation(false)// default
      QueryParser parser=new QueryParser(Version.LUCENE_29,"color",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("color:red OR shape:square"));
        br.setCount(10);
        br.setOffset(0);
       
        br.setSort(new SortField[]{SortField.FIELD_SCORE});
View Full Code Here

  }

  public void testBrowseWithQuery(){
    try{
      BrowseRequest br=new BrowseRequest();
      QueryParser parser=new QueryParser(Version.LUCENE_29,"shape",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("square OR circle"));
        br.setCount(10);
        br.setOffset(0);
       
        BrowseSelection sel=new BrowseSelection("color");
View Full Code Here

 
  public void testIndexReaderReopen() throws Exception{
    Directory idxDir = new RAMDirectory();
    Document[] docs = buildData();
   
    IndexWriter writer = new IndexWriter(idxDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
    writer.addDocument(docs[0]);
    writer.optimize();
    writer.commit();
   
    IndexReader idxReader = IndexReader.open(idxDir,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,_fconf);

   
    for (int i=1;i<docs.length;++i){
      Document doc = docs[i];
      int numDocs = boboReader.numDocs();
      BoboIndexReader reader = (BoboIndexReader)boboReader.reopen(true);
      assertSame(boboReader,reader);
     
      Directory tmpDir = new RAMDirectory();
      IndexWriter subWriter = new IndexWriter(tmpDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
      subWriter.addDocument(doc);
      subWriter.optimize();
      subWriter.close();
      writer.addIndexesNoOptimize(new Directory[]{tmpDir});
      writer.commit();
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.standard.StandardAnalyzer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.