Examples of LuceneConfig


Examples of com.esri.gpt.catalog.lucene.LuceneConfig

    this.operations = new AsnOperations();
    AsnIndexReferences indexRefs = this.indexReferences;
    ApplicationConfiguration appCfg = ApplicationContext.getInstance().getConfiguration();
    CatalogConfiguration catCfg = appCfg.getCatalogConfiguration();
    StringAttributeMap catParams = catCfg.getParameters();
    LuceneConfig luceneCfg = catCfg.getLuceneConfig();
   
    // API operations
    AsnOperation op = new AsnOperation();
    op.setHandlerClass("com.esri.gpt.server.assertion.handler.AsnApiHandler");
    op.setSubject(new AsnSubject(AsnConstants.APP_URN_PREFIX));
    op.getSubject().setRequiresValuePart(false);
    op.setPredicate(new AsnPredicate(AsnConstants.APP_URN_PREFIX+":assertion:operations"));
    op.setAuthPolicy(new AsnAuthPolicy());
    op.getAuthPolicy().setAuthenticationRequired(false);
    op.getAuthPolicy().setQueryPrincipals(new AsnPrincipals());
    op.getAuthPolicy().getQueryPrincipals().add(AsnConstants.PRINCIPAL_ANY);
    this.operations.add(op);
   
    // root index reference
    String val = Val.chkStr(catParams.getValue("assertion.index.allowNonLocalResourceIds"));
    this.allowNonLocalResourceIds = val.equalsIgnoreCase("true");
    AsnIndexReference rootIndexRef = new AsnIndexReference();
    val = Val.chkStr(catParams.getValue("assertion.index.enabled"));
    rootIndexRef.setEnabled(!val.equalsIgnoreCase("false"));
    val = Val.chkStr(catParams.getValue("assertion.index.location"));
    rootIndexRef.setIndexLocation(val);
    rootIndexRef.setUseNativeFSLockFactory(luceneCfg.getUseNativeFSLockFactory());
    rootIndexRef.setWriteLockTimeout(luceneCfg.getWriteLockTimeout());
    if (!rootIndexRef.getEnabled()) {
      LOGGER.config("assertion.index.enabled=false");
      return;
    } else if (rootIndexRef.getIndexLocation().length() == 0) {
      String msg = "The configured assertion.index.location parameter is invalid.";
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

        .getHandlerContext(Geonet.CONTEXT_NAME);
    ServiceConfig handlerConfig = gc.getBean(ServiceConfig.class);
    String luceneConfigXmlFile = handlerConfig
        .getMandatoryValue(Geonet.Config.LUCENE_CONFIG);

    LuceneConfig lc = context.getBean(LuceneConfig.class);
        lc.configure(luceneConfigXmlFile);

    Logger logger = context.getLogger();
    logger.info("  - Lucene configuration is:");
    String config = lc.toString();
    logger.info(config);

    return new Element("response")
      .addContent(new Element("status").setText(status))
      .addContent(new Element("config").setText(config));
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

        logger.info("  - Log in asynch mode: " + logAsynch);

        String luceneTermsToExclude = "";
        luceneTermsToExclude = handlerConfig.getMandatoryValue(Geonet.Config.STAT_LUCENE_TERMS_EXCLUDE);

        LuceneConfig lc = _applicationContext.getBean(LuceneConfig.class);
        lc.configure(luceneConfigXmlFile);
        logger.info("  - Lucene configuration is:");
        logger.info(lc.toString());

        try {
            _applicationContext.getBean(DataStore.class);
        } catch (NoSuchBeanDefinitionException e) {
            DataStore dataStore = createShapefileDatastore(luceneDir);
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

    public void testResetWaitsForAllReadersToClose() throws Exception {
        GeonetworkDataDirectory datadir = Mockito.mock(GeonetworkDataDirectory.class);
        Mockito.when(datadir.getLuceneDir()).thenReturn(folder.getRoot());
        FSDirectoryFactory directoryFactory = new FSDirectoryFactory();
        directoryFactory.setDataDir(datadir);
        LuceneConfig luceneConfig = Mockito.mock(LuceneConfig.class);
        Mockito.when(luceneConfig.commitInterval()).thenReturn(1L);
        Mockito.when(luceneConfig.useNRTManagerReopenThread()).thenReturn(false);
        final LuceneIndexLanguageTracker tracker = new LuceneIndexLanguageTracker(directoryFactory, luceneConfig);

        final IndexAndTaxonomy acquire = addDocumentAndAssertCorrectlyAdded(tracker);

        final boolean[] tryingToReset = new boolean[1];
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

    public void testResetThrowsExceptionWhenReadersAreNotClosed() throws Exception {
        GeonetworkDataDirectory datadir = Mockito.mock(GeonetworkDataDirectory.class);
        Mockito.when(datadir.getLuceneDir()).thenReturn(folder.getRoot());
        FSDirectoryFactory directoryFactory = new FSDirectoryFactory();
        directoryFactory.setDataDir(datadir);
        LuceneConfig luceneConfig = Mockito.mock(LuceneConfig.class);
        Mockito.when(luceneConfig.commitInterval()).thenReturn(1L);
        Mockito.when(luceneConfig.useNRTManagerReopenThread()).thenReturn(false);
        final LuceneIndexLanguageTracker tracker = new LuceneIndexLanguageTracker(directoryFactory, luceneConfig);

        addDocumentAndAssertCorrectlyAdded(tracker);

        tracker.reset(500);
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

        GeonetworkDataDirectory datadir = Mockito.mock(GeonetworkDataDirectory.class);
        final File root = folder.getRoot();
        Mockito.when(datadir.getLuceneDir()).thenReturn(root);
        FSDirectoryFactory directoryFactory = new FSDirectoryFactory();
        directoryFactory.setDataDir(datadir);
        LuceneConfig luceneConfig = Mockito.mock(LuceneConfig.class);
        Mockito.when(luceneConfig.commitInterval()).thenReturn(1L);
        Mockito.when(luceneConfig.useNRTManagerReopenThread()).thenReturn(false);

        createAndLockFilesAndResetTracker(directoryFactory, luceneConfig, true);

        assertEquals(FSDirectoryFactory.NON_SPATIAL_DIR + "_" + 1, directoryFactory.getIndexDir().getName());
        assertEquals(FSDirectoryFactory.TAXONOMY_DIR + "_" + 1, directoryFactory.getTaxonomyDir().getName());
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

    public void testCantOpenNewReaderDuringReset() throws Exception {
        GeonetworkDataDirectory datadir = Mockito.mock(GeonetworkDataDirectory.class);
        Mockito.when(datadir.getLuceneDir()).thenReturn(folder.getRoot());
        FSDirectoryFactory directoryFactory = new FSDirectoryFactory();
        directoryFactory.setDataDir(datadir);
        LuceneConfig luceneConfig = Mockito.mock(LuceneConfig.class);
        Mockito.when(luceneConfig.commitInterval()).thenReturn(1L);
        Mockito.when(luceneConfig.useNRTManagerReopenThread()).thenReturn(false);
        final LuceneIndexLanguageTracker tracker = new LuceneIndexLanguageTracker(directoryFactory, luceneConfig);

        final IndexAndTaxonomy acquire = addDocumentAndAssertCorrectlyAdded(tracker);

        final boolean[] tryingToReset = new boolean[1];
View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig

   */
  public List<String> getAllUuids(int maxHits, ServiceContext context) throws Exception {

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SearchManager sm = gc.getBean(SearchManager.class);
    LuceneConfig luceneConfig = getLuceneConfig();
        IndexAndTaxonomy indexAndTaxonomy = sm.getIndexReader(null, _searchToken);

        try {
            Log.debug(Geonet.CSW_SEARCH, "Found searcher with " + indexAndTaxonomy.version + " comparing with " + _searchToken);
            if (indexAndTaxonomy.version != _searchToken && !(!luceneConfig.useNRTManagerReopenThread() || Boolean.parseBoolean(System.getProperty(LuceneConfig.USE_NRT_MANAGER_REOPEN_THREAD)))) {
                throw new SearchExpiredEx("Search has expired/timed out - start a new search");
            }
            GeonetworkMultiReader _reader = indexAndTaxonomy.indexReader;
            Pair<TopDocs, Element> searchResults = LuceneSearcher.doSearchAndMakeSummary(maxHits, 0, maxHits, _lang.presentationLanguage,
                    luceneConfig.getTaxonomy().get(ResultType.RESULTS.toString()), luceneConfig.getTaxonomyConfiguration(),
                    _reader, _query, wrapSpatialFilter(), _sort, null, false,
                    luceneConfig.isTrackDocScores(), luceneConfig.isTrackMaxScore(), luceneConfig.isDocsScoredInOrder());
            TopDocs tdocs = searchResults.one();
            Element summary = searchResults.two();

            int numHits = Integer.parseInt(summary.getAttributeValue("count"));

View Full Code Here

Examples of org.fao.geonet.kernel.search.LuceneConfig


    boolean requestedLanguageOnTop = sm.getSettingInfo().getRequestedLanguageOnTop();
   
        Query data;
        LuceneConfig luceneConfig = getLuceneConfig();
        if (luceneExpr == null) {
            data = null;
            Log.info(Geonet.CSW_SEARCH, "LuceneSearcher made null query");
        } else {
            PerFieldAnalyzerWrapper analyzer = SearchManager.getAnalyzer(_lang.analyzerLanguage, true);
            SettingInfo.SearchRequestLanguage requestedLanguageOnly = sm.getSettingInfo().getRequestedLanguageOnly();
            data = LuceneSearcher.makeLocalisedQuery(luceneExpr,
                analyzer, luceneConfig, _lang.presentationLanguage, requestedLanguageOnly);
            Log.info(Geonet.CSW_SEARCH, "LuceneSearcher made query:\n" + data.toString());
        }

        Query cswCustomFilterQuery = null;
        Log.info(Geonet.CSW_SEARCH,"LuceneSearcher cswCustomFilter:\n" + cswServiceSpecificContraint);
        if (StringUtils.isNotEmpty(cswServiceSpecificContraint)) {
            cswCustomFilterQuery = getCswServiceSpecificConstraintQuery(cswServiceSpecificContraint, luceneConfig);
            Log.info(Geonet.CSW_SEARCH,"LuceneSearcher cswCustomFilterQuery:\n" + cswCustomFilterQuery);
        }

    Query groups = getGroupsQuery(context);
    if (sort == null) {
      List<Pair<String, Boolean>> fields = Collections.singletonList(Pair.read(Geonet.SearchResult.SortBy.RELEVANCE, true));
            sort = LuceneSearcher.makeSort(fields, _lang.presentationLanguage, requestedLanguageOnTop);
    }

    // --- put query on groups in AND with lucene query

    BooleanQuery query = new BooleanQuery();

    // FIXME : DO I need to fix that here ???
    // BooleanQuery.setMaxClauseCount(1024); // FIXME : using MAX_VALUE
    // solve
    // // partly the org.apache.lucene.search.BooleanQuery$TooManyClauses
    // // problem.
    // // Improve index content.

    BooleanClause.Occur occur = LuceneUtils.convertRequiredAndProhibitedToOccur(true, false);
    if (data != null) {
      query.add(data, occur);
        }
    query.add(groups, occur);

        if (cswCustomFilterQuery != null) {
            query.add(cswCustomFilterQuery, occur);
        }

    // --- proper search
        if(Log.isDebugEnabled(Geonet.CSW_SEARCH))
            Log.debug(Geonet.CSW_SEARCH, "Lucene query: " + query.toString());

        int numHits = startPosition + maxRecords;

        updateRegionsInSpatialFilter(context, filterExpr);
    // TODO Handle NPE creating spatial filter (due to constraint)
        _filter = sm.getSpatial().filter(query, Integer.MAX_VALUE, filterExpr, filterVersion);
       
        boolean buildSummary = resultType == ResultType.RESULTS_WITH_SUMMARY;
        // get as many results as instructed or enough for search summary
        if (buildSummary) {
            numHits = Math.max(maxHitsInSummary, numHits);
        }
    // record globals for reuse
    _query = query;
    _sort = sort;
   
      ServiceConfig config = new ServiceConfig();
      String geomWkt = null;
      LuceneSearcher.logSearch(context, config, _query, numHits, _sort, geomWkt, sm);

    Pair<TopDocs,Element> searchResults = LuceneSearcher.doSearchAndMakeSummary(numHits, startPosition - 1,
                maxRecords, _lang.presentationLanguage,
                luceneConfig.getTaxonomy().get(resultType.toString()), luceneConfig.getTaxonomyConfiguration(),
                reader, _query, wrapSpatialFilter(),
                _sort, taxonomyReader, buildSummary, luceneConfig.isTrackDocScores(), luceneConfig.isTrackMaxScore(),
                luceneConfig.isDocsScoredInOrder()
    );
    TopDocs hits = searchResults.one();
    Element summary = searchResults.two();

    numHits = Integer.parseInt(summary.getAttributeValue("count"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.