Package org.apache.lucene.analysis.miscellaneous

Examples of org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper


    public void doAddData(String fileContent, String filePath, String fileName) {
        try {

            if (Vars.writerForLucene != null) {
                Document doc = new Document();
                PerFieldAnalyzerWrapper fieldAnalyzer;

                if (lang == null) {
                    if (fileContent.length() < 1000) {
                        lang = Vars.TextCategorizerLocal.categorize(
                                fileContent.substring(0, fileContent.length()));
View Full Code Here


     * @param language A string containing the name of the language.
     * @return Returns the type of Analyzer.
     */
    public PerFieldAnalyzerWrapper getAnalyzer(String language) {
        if (language.equals("russian")) {
            return (new PerFieldAnalyzerWrapper(new RussianAnalyzer(Version.LUCENE_40)));
        }
        if (language.equals("english")) {
            return (new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_40)));
        }

        return (new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_40)));
    }
View Full Code Here

        Analyzer skosAnalyzer = new SKOSAnalyzer(indexPath, skosFile, ExpansionType.URI);

        /* Define different analyzers for different fields */
        Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>();
        analyzerPerField.put("subject", skosAnalyzer);
        PerFieldAnalyzerWrapper indexAnalyzer = new PerFieldAnalyzerWrapper(
                new SimpleAnalyzer(SKOSAnalysisPlugin.getLuceneVersion()), analyzerPerField);

        /* setting up a writer with a default (simple) analyzer */
        writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(SKOSAnalysisPlugin.getLuceneVersion(),
                indexAnalyzer));
View Full Code Here

                ExpansionType.LABEL);

        /* Define different analyzers for different fields */
        Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>();
        analyzerPerField.put("subject", skosAnalyzer);
        PerFieldAnalyzerWrapper indexAnalyzer = new PerFieldAnalyzerWrapper(
                new SimpleAnalyzer(SKOSAnalysisPlugin.getLuceneVersion()), analyzerPerField);

        /* setting up a writer with a default (simple) analyzer */
        writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(SKOSAnalysisPlugin.getLuceneVersion(),
                indexAnalyzer));
View Full Code Here

  public Indexer(Directory dir, Language language) {
    try {
      final Map<String, Analyzer> analyzerMap = new HashMap<String, Analyzer>();
      analyzerMap.put(FIELD_NAME, new LanguageToolAnalyzer(LUCENE_VERSION, new JLanguageTool(language), false));
      analyzerMap.put(FIELD_NAME_LOWERCASE, new LanguageToolAnalyzer(LUCENE_VERSION, new JLanguageTool(language), true));
      final Analyzer analyzer = new PerFieldAnalyzerWrapper(new DoNotUseAnalyzer(), analyzerMap);
      final IndexWriterConfig writerConfig = new IndexWriterConfig(LUCENE_VERSION, analyzer);
      writerConfig.setOpenMode(OpenMode.CREATE);
      writer = new IndexWriter(dir, writerConfig);
      sentenceTokenizer = language.getSentenceTokenizer();
    } catch (Exception e) {
View Full Code Here

    // TODO: avoid duplication - use Indexer.java!
    final Map<String, Analyzer> analyzerMap = new HashMap<>();
    analyzerMap.put(FIELD_NAME, new LanguageToolAnalyzer(LUCENE_VERSION, new JLanguageTool(language), false));
    analyzerMap.put(FIELD_NAME_LOWERCASE, new LanguageToolAnalyzer(LUCENE_VERSION, new JLanguageTool(language), true));
    final Analyzer analyzer = new PerFieldAnalyzerWrapper(new DoNotUseAnalyzer(), analyzerMap);

    final IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, analyzer);
    final IndexWriter writer = new IndexWriter(directory, config);
    try {
      addDocument(writer, "How do you thin about this wonderful idea?");
View Full Code Here

          if (analyzer != null) {
            analyzerPerField.put(field, analyzer);
          }
        }
       
        this.analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(VER), analyzerPerField) ;

        // force creation of the index if it don't exist
        // otherwise if we get a search before data is written we get an
        // exception
        startIndexing() ;
View Full Code Here

          if (analyzer != null) {
            analyzerPerField.put(field, analyzer);
          }
        }
       
        this.analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(VER), analyzerPerField) ;

        // force creation of the index if it don't exist
        // otherwise if we get a search before data is written we get an
        // exception
        startIndexing() ;
View Full Code Here

        // entity and graph fields and StandardAnalyzer for all other
        Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>() ;
        analyzerPerField.put(def.getEntityField(), new KeywordAnalyzer()) ;
        if ( def.getGraphField() != null )
            analyzerPerField.put(def.getGraphField(), new KeywordAnalyzer()) ;
        this.analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(VER), analyzerPerField) ;

        // force creation of the index if it don't exist
        // otherwise if we get a search before data is written we get an
        // exception
        startIndexing() ;
View Full Code Here

     *
     * @param stopwords
     * @return
     */
  private static PerFieldAnalyzerWrapper createHardCodedPerFieldAnalyzerWrapper(Set<String> stopwords, char[] ignoreChars) {
        PerFieldAnalyzerWrapper pfaw;
        Analyzer geoNetworkAnalyzer = SearchManager.createGeoNetworkAnalyzer(stopwords, ignoreChars);
    Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
    analyzers.put(LuceneIndexField.UUID, new GeoNetworkAnalyzer());
    analyzers.put(LuceneIndexField.PARENTUUID, new GeoNetworkAnalyzer());
    analyzers.put(LuceneIndexField.OPERATESON, new GeoNetworkAnalyzer());
    analyzers.put(LuceneIndexField.SUBJECT, new KeywordAnalyzer());
   
    pfaw = new PerFieldAnalyzerWrapper(geoNetworkAnalyzer, analyzers );
        return pfaw;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper

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.