Package org.apache.lucene.analysis.standard

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


      }
      wc++;
        }
        File segments = new File(lucenePath + File.separator + SEGMENTS);
        boolean bCreate = !segments.exists();
        return new IndexWriter(lucenePath,new StandardAnalyzer(),bCreate);
    }
View Full Code Here


        path.append(File.separator);
        path.append(SEGMENTS);
        File segments = new File(path.toString());
        try{
          boolean bCreate = !segments.exists();
          return new IndexWriter(index_path,new StandardAnalyzer(),bCreate);
        }finally{
          path = null;
          segments = null;
          rp = null;
        }
View Full Code Here

      indexName = indexFile.getCanonicalPath();
      directory = FSDirectory.getDirectory(indexName);
      if (create) {
        log.debug("Initialize index: '" + indexFile + "'");
        IndexWriter iw = new IndexWriter(directory,
            new StandardAnalyzer(), create);
        iw.close();
      }
    } catch (IOException e) {
      throw new HibernateException("Unable to initialize index: "
          + indexFile, e);
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    @Transactional(readOnly = true)
    public <T extends DomainEntity> List<T> search(Class<T> clazz, String field, String query, int offset, int number) {
        FullTextEntityManager fullTextEntityManager = Search.createFullTextEntityManager(getEntityManager());
        MultiFieldQueryParser parser = new MultiFieldQueryParser(getAllIndexedFields(clazz, field), new StandardAnalyzer());
        try {
            org.apache.lucene.search.Query parsedquery = parser.parse(query.trim().replaceAll(" ", "* ") + "*");
            FullTextQuery hq = fullTextEntityManager.createFullTextQuery(parsedquery, clazz);
            hq.setMaxResults(number > 0 ? number : MAX_RESULTS);
            hq.setFirstResult(offset > 0 ? offset : 0);
View Full Code Here

                    ## LUCENE2 end ##*/
                    //## LUCENE3 begin ##
                    File f = new File(path);
                    Directory indexDir = FSDirectory.open(f);
                    boolean recreate = !IndexReader.indexExists(indexDir);
                    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
                    IndexWriter writer = new IndexWriter(indexDir, analyzer,
                            recreate, IndexWriter.MaxFieldLength.UNLIMITED);
                    //see http://wiki.apache.org/lucene-java/NearRealtimeSearch
                    IndexReader reader = writer.getReader();
                    access = new IndexAccess();
View Full Code Here

    this.type = type;
    this.fem = fem;
  }

  public List<E> list(String search, String... fields) {
    return this.list(search, new StandardAnalyzer(), fields);
  }
View Full Code Here

    else
      return null;
  }

  public Page<E> page(Pagination pagination, String search, String... fields) {
    return this.page(pagination, search, new StandardAnalyzer(), fields);
  }
View Full Code Here

  private Query buildQuery(String search, String... fields) {
    Query query = null;
    try {
      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,
          new StandardAnalyzer());
      if (search != null && !search.trim().equals("")) {
        StringBuffer cds = new StringBuffer();
        // 分词并构造组合查询条件
        final String[] tmp_conditions = search.split(" ");
        int index = 0;
View Full Code Here

      mSearchBean.getKeyword() != null &&
      !mSearchBean.getKeyword().equals(""))
    {
      try
      {
        query = QueryParser.parse(mSearchBean.getKeyword(), "message", new StandardAnalyzer());
      }
      catch (org.apache.lucene.queryParser.ParseException e)
      {
        // just ignore it, nothing I can do
      }
View Full Code Here

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

          if (!highlighted.equals(""))
          {
            encoded_message = highlighted;
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.