List of usage examples for org.apache.lucene.search BooleanQuery setMaxClauseCount
public static void setMaxClauseCount(int maxClauseCount)
From source file:nicta.com.au.patent.queryreduction.PatentMMRQueryReduction.java
License:Apache License
/** * Performs Rocchio's query expansion with pseudo feedback for each fields * separatlly qm = alpha * query + ( beta / relevanDocsCount ) * Sum ( rel * docs vector )//from www . j av a2s. c om * * @param query * * @return expandedQuery * * @throws IOException * @throws ParseException */ @Override public Query expandQuery(PatentQuery query) throws ParseException, IOException { IndexReader ir = searcher.getIndexReader(); BooleanQuery bQuery = new BooleanQuery(); BooleanQuery bQueryFieldsExpanded = new BooleanQuery(); BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE); //***************************************************************** //**************** Compute the PRF for field (i)******************* //***************************************************************** TotalHitCountCollector collector = new TotalHitCountCollector(); searcher.search(query.parse(), collector); TopDocs hits = searcher.search(query.parse(), Math.max(1, collector.getTotalHits())); // Compute PRF set // System.err.println(hits.totalHits + " total matching documents for field " + query.getFields()[i] + "."); Query expandedQuery = null; MMRQueryReduction qe = new MMRQueryReduction(hits, ir, MMRQE_LAMBDA, PatentQuery.getFields()[source], Nbr_Docs, Nbr_Terms); for (int i = 1; i < PatentQuery.getFields().length; i++) { if (query.getQueries()[i] != null && !query.getQueries()[i].equals("") && (i != 4 || i != 6) && query.getBoosts().get(PatentQuery.getFields()[i]) != 0) { QueryParser qp = new QueryParser(Version.LUCENE_48, PatentQuery.getFields()[i], new StandardAnalyzer(Version.LUCENE_48)); // BooleanQuery bQueryFields = new BooleanQuery();// Contain a field to make the PRF field by field Query q = qp.parse(query.getQueries()[i]); // if (query.isFilter()) { // Query filter = new QueryParser(Version.LUCENE_48, PatentQuery.getFields()[0], // new StandardAnalyzer(Version.LUCENE_48)).parse(query.getQueries()[0]); // bQueryFields.add(filter, BooleanClause.Occur.MUST); // } // if (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0) { // bQueryFields.add(q, BooleanClause.Occur.MUST); // } if (expandedQuery == null) { expandedQuery = qe.reduceQuery(q, PatentQuery.getFields()[i]); } else { BooleanQuery bq = ((BooleanQuery) expandedQuery).clone(); BooleanQuery bq2 = new BooleanQuery(); for (BooleanClause bc : bq.clauses()) { TermQuery tq = (TermQuery) bc.getQuery(); Term term = new Term(PatentQuery.getFields()[i], tq.getTerm().text()); TermQuery tq2 = new TermQuery(term); tq2.setBoost(tq.getBoost()); bq2.add(tq2, BooleanClause.Occur.SHOULD); } expandedQuery = bq2; } bQueryFieldsExpanded.add(expandedQuery, BooleanClause.Occur.SHOULD);// Compute the new expanded query based on PRF set // System.err.println("Expanded Query: " + expandedQuery); // hits = searcher.search(expandedQuery, 100); // System.err.println(hits.totalHits + " total matching documents"+ query.getFields()[i] + "."); } } if (query.isFilter()) { Query q = new QueryParser(Version.LUCENE_48, PatentQuery.getFields()[0], new StandardAnalyzer(Version.LUCENE_48)).parse(query.getQueries()[0]); q.setBoost(query.getBoosts().get(PatentQuery.getFields()[0])); bQuery.add(q, BooleanClause.Occur.MUST); } bQuery.add(bQueryFieldsExpanded, BooleanClause.Occur.MUST); // TopDocs hits = searcher.search(bQuery, 100); // System.err.println(hits.totalHits + " total matching documents."); return bQuery; }
From source file:nl.inl.blacklab.search.Searcher.java
License:Apache License
/** * Open an index./*from ww w .jav a2 s .c o m*/ * * @param indexDir the index directory * @param indexMode if true, open in index mode; if false, open in search mode. * @param createNewIndex if true, delete existing index in this location if it exists. * @param indexTemplateFile JSON file to use as template for index structure / metadata * (if creating new index) * @throws IOException */ private Searcher(File indexDir, boolean indexMode, boolean createNewIndex, File indexTemplateFile) throws IOException { this.indexMode = indexMode; if (!indexMode && createNewIndex) throw new RuntimeException("Cannot create new index, not in index mode"); if (!createNewIndex) { if (!indexMode || VersionFile.exists(indexDir)) { if (!isIndex(indexDir)) { throw new RuntimeException( "BlackLab index has wrong type or version! " + VersionFile.report(indexDir)); } } } logger.debug("Constructing Searcher..."); if (indexMode) { indexWriter = openIndexWriter(indexDir, createNewIndex); reader = DirectoryReader.open(indexWriter, false); } else { // Open Lucene index reader = DirectoryReader.open(FSDirectory.open(indexDir)); } this.indexLocation = indexDir; // Determine the index structure indexStructure = new IndexStructure(reader, indexDir, createNewIndex, indexTemplateFile); isEmptyIndex = indexStructure.isNewIndex(); createAnalyzers(); // Detect and open the ContentStore for the contents field if (!createNewIndex) { ComplexFieldDesc mainContentsField = indexStructure.getMainContentsField(); if (mainContentsField == null) { if (!indexMode) { if (!isEmptyIndex) throw new RuntimeException("Could not detect main contents field"); // Empty index. Set a default name for the contents field. // Searching an empty index will fail and should not be attempted. this.mainContentsFieldName = Searcher.DEFAULT_CONTENTS_FIELD_NAME; } } else { this.mainContentsFieldName = mainContentsField.getName(); // See if we have a punctuation forward index. If we do, // default to creating concordances using that. if (mainContentsField.hasPunctuation()) { defaultConcsType = ConcordanceType.FORWARD_INDEX; } } // Register content stores for (String cfn : indexStructure.getComplexFields()) { if (indexStructure.getComplexFieldDesc(cfn).hasContentStore()) { File dir = new File(indexDir, "cs_" + cfn); if (!dir.exists()) { dir = new File(indexDir, "xml"); // OLD, should eventually be removed } if (dir.exists()) { registerContentStore(cfn, openContentStore(dir)); } } } } indexSearcher = new IndexSearcher(reader); // Make sure large wildcard/regex expansions succeed BooleanQuery.setMaxClauseCount(100000); // Open the forward indices if (!createNewIndex) openForwardIndices(); logger.debug("Done."); }
From source file:nl.inl.blacklab.search.SearcherImpl.java
License:Apache License
/** * Open an index.//from w w w. ja v a2 s. co m * * @param indexDir the index directory * @param indexMode if true, open in index mode; if false, open in search mode. * @param createNewIndex if true, delete existing index in this location if it exists. * @param indexTemplateFile JSON file to use as template for index structure / metadata * (if creating new index) * @throws IOException */ SearcherImpl(File indexDir, boolean indexMode, boolean createNewIndex, File indexTemplateFile) throws IOException { this.indexMode = indexMode; if (!indexMode && createNewIndex) throw new RuntimeException("Cannot create new index, not in index mode"); if (!createNewIndex) { if (!indexMode || VersionFile.exists(indexDir)) { if (!isIndex(indexDir)) { throw new IllegalArgumentException( "Not a BlackLab index, or wrong version! " + VersionFile.report(indexDir)); } } } // If we didn't provide log4j.properties on the classpath, initialise it using default settings. LogUtil.initLog4jIfNotAlready(); logger.debug("Constructing Searcher..."); if (indexMode) { logger.debug(" Opening IndexWriter..."); indexWriter = openIndexWriter(indexDir, createNewIndex, null); logger.debug(" Opening corresponding IndexReader..."); reader = DirectoryReader.open(indexWriter, false); } else { // Open Lucene index logger.debug(" Following symlinks..."); Path indexPath = indexDir.toPath(); while (Files.isSymbolicLink(indexPath)) { // Resolve symlinks, as FSDirectory.open() can't handle them indexPath = Files.readSymbolicLink(indexPath); } logger.debug(" Opening IndexReader..."); reader = DirectoryReader.open(FSDirectory.open(indexPath)); } this.indexLocation = indexDir; // Determine the index structure logger.debug(" Determining index structure..."); indexStructure = new IndexStructure(reader, indexDir, createNewIndex, indexTemplateFile); isEmptyIndex = indexStructure.isNewIndex(); // TODO: we need to create the analyzer before opening the index, because // we can't change the analyzer attached to the IndexWriter (and passing a different // analyzer in addDocument() is going away in Lucene 5.x). // For now, if we're in index mode, we re-open the index with the analyzer we determined. logger.debug(" Creating analyzers..."); createAnalyzers(); if (indexMode) { // Re-open the IndexWriter with the analyzer we've created above (see comment above) logger.debug(" Re-opening IndexWriter with newly created analyzers..."); reader.close(); reader = null; indexWriter.close(); indexWriter = null; indexWriter = openIndexWriter(indexDir, createNewIndex, analyzer); logger.debug(" IndexReader too..."); reader = DirectoryReader.open(indexWriter, false); } // Detect and open the ContentStore for the contents field if (!createNewIndex) { logger.debug(" Determining main contents field name..."); ComplexFieldDesc mainContentsField = indexStructure.getMainContentsField(); if (mainContentsField == null) { if (!indexMode) { if (!isEmptyIndex) throw new RuntimeException("Could not detect main contents field"); // Empty index. Set a default name for the contents field. // Searching an empty index will fail and should not be attempted. this.mainContentsFieldName = Searcher.DEFAULT_CONTENTS_FIELD_NAME; } } else { this.mainContentsFieldName = mainContentsField.getName(); // See if we have a punctuation forward index. If we do, // default to creating concordances using that. if (mainContentsField.hasPunctuation()) { hitsSettings.setConcordanceType(ConcordanceType.FORWARD_INDEX); } } // Register content stores logger.debug(" Opening content stores..."); for (String cfn : indexStructure.getComplexFields()) { if (indexStructure.getComplexFieldDesc(cfn).hasContentStore()) { File dir = new File(indexDir, "cs_" + cfn); if (!dir.exists()) { dir = new File(indexDir, "xml"); // OLD, should eventually be removed } if (dir.exists()) { logger.debug(" " + dir + "..."); registerContentStore(cfn, openContentStore(dir, false)); } } } } logger.debug(" Opening IndexSearcher..."); indexSearcher = new IndexSearcher(reader); // Make sure large wildcard/regex expansions succeed logger.debug(" Setting maxClauseCount..."); BooleanQuery.setMaxClauseCount(100000); // Open the forward indices if (!createNewIndex) { logger.debug(" Opening forward indices..."); openForwardIndices(); } logger.debug("Done."); }
From source file:nl.uva.DataHandler.Retrieval.java
private ScoreDoc[] searchIndex(String qText, Filter filter) throws IOException, Throwable { log.info("size of query: " + qText.length()); boolean retry = true; ScoreDoc[] hits = null;/*from w ww .j a v a2 s.c o m*/ while (retry) { try { retry = false; Query q = this.queryCreator(qText); TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerReq); this.iSearcher.search(q, filter, collector); // this.iSearcher.search(q, collector); hits = collector.topDocs().scoreDocs; return hits; } // catch (BooleanQuery.TooManyClauses e) catch (Exception e) { // Double the number of boolean queries allowed. // The default is in org.apache.lucene.search.BooleanQuery and is 1024. String defaultQueries = Integer.toString(BooleanQuery.getMaxClauseCount()); int oldQueries = Integer .parseInt(System.getProperty("org.apache.lucene.maxClauseCount", defaultQueries)); int newQueries = oldQueries * 2; log.error("Too many hits for query..., changing maxClauseCount to: " + newQueries); // log.error("Too many hits for query: " + oldQueries + ". Increasing to " + newQueries, e); System.setProperty("org.apache.lucene.maxClauseCount", Integer.toString(newQueries)); BooleanQuery.setMaxClauseCount(newQueries); retry = true; } } return hits; }
From source file:nl.uva.expose.clustering.SimGraphMaker.java
public HashMap<String, Double> searchAndReturnResults(String queryText, String qId) throws IOException, ParseException { queryText = queryText.replaceAll("AND", "and").replaceAll("OR", "or").replaceAll("NOT", "not"); // to avoid boolean operation! QueryParser qParser = new QueryParser(Version.LUCENE_CURRENT, field, this.analyzer); BooleanQuery.setMaxClauseCount(queryText.split("\\s+").length); Query q = qParser.parse(QueryParser.escape(queryText)); Similarity simFunc = new BM25Similarity(); IndexSearcher isearcher = new IndexSearcher(this.ireader); isearcher.setSimilarity(simFunc);/*from w ww. j a v a2 s. co m*/ TopFieldCollector tfc = TopFieldCollector.create(Sort.RELEVANCE, ireader.numDocs(), true, true, true, false); // TopFieldCollector tfc = TopFieldCollector.create(Sort.RELEVANCE,20, true, true, true, false); isearcher.search(q, tfc); TopDocs results = tfc.topDocs(); ScoreDoc[] hits = results.scoreDocs; return fillQueryResultList(hits, qId); }
From source file:nl.uva.mlc.eurovoc.irengine.Retrieval.java
public HashMap<String, Feature> searchAndReturnResults(String queryText, String qId) throws IOException, ParseException { queryText = queryText.replaceAll("AND", "and").replaceAll("OR", "or").replaceAll("NOT", "not"); // to avoid boolean operation! QueryParser qParser = new QueryParser(Version.LUCENE_CURRENT, field, this.analyzer); BooleanQuery.setMaxClauseCount(queryText.split("\\s+").length); Query q = qParser.parse(QueryParser.escape(queryText)); this.simFunction = SIM_FUNCS[SimilarityFunction.valueOf(SimFName).ordinal()]; Similarity simFunc = this.simFunction; IndexSearcher isearcher = new IndexSearcher(this.ireader); isearcher.setSimilarity(simFunc);//from w w w.j ava 2s . co m TopFieldCollector tfc = TopFieldCollector.create(Sort.RELEVANCE, ireader.numDocs(), true, true, true, false); isearcher.search(q, tfc); TopDocs results = tfc.topDocs(); ScoreDoc[] hits = results.scoreDocs; return fillQueryResultList(hits, qId); }
From source file:org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory.java
License:Open Source License
/** * Set the max number of queries in a llucen boolean query * /*ww w . j a v a 2 s. com*/ * @param queryMaxClauses int */ @Override public void setQueryMaxClauses(int queryMaxClauses) { this.queryMaxClauses = queryMaxClauses; BooleanQuery.setMaxClauseCount(this.queryMaxClauses); }
From source file:org.apache.archiva.indexer.search.MavenRepositorySearch.java
License:Apache License
/** * @see RepositorySearch#search(String, List, String, SearchResultLimits, List) *//* ww w . j av a2 s. com*/ @Override public SearchResults search(String principal, List<String> selectedRepos, String term, SearchResultLimits limits, List<String> previousSearchTerms) throws RepositorySearchException { List<String> indexingContextIds = addIndexingContexts(selectedRepos); // since upgrade to nexus 2.0.0, query has changed from g:[QUERIED TERM]* to g:*[QUERIED TERM]* // resulting to more wildcard searches so we need to increase max clause count BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE); BooleanQuery q = new BooleanQuery(); if (previousSearchTerms == null || previousSearchTerms.isEmpty()) { constructQuery(term, q); } else { for (String previousTerm : previousSearchTerms) { BooleanQuery iQuery = new BooleanQuery(); constructQuery(previousTerm, iQuery); q.add(iQuery, Occur.MUST); } BooleanQuery iQuery = new BooleanQuery(); constructQuery(term, iQuery); q.add(iQuery, Occur.MUST); } // we retun only artifacts without classifier in quick search, olamy cannot find a way to say with this field empty // FIXME cannot find a way currently to setup this in constructQuery !!! return search(limits, q, indexingContextIds, NoClassifierArtifactInfoFilter.LIST, selectedRepos, true); }
From source file:org.apache.blur.thrift.ThriftBlurShardServer.java
License:Apache License
public static ThriftServer createServer(int serverIndex, BlurConfiguration configuration) throws Exception { Configuration config = BlurUtil.newHadoopConfiguration(configuration); TableContext.setSystemBlurConfiguration(configuration); TableContext.setSystemConfiguration(config); String bindAddress = configuration.get(BLUR_SHARD_BIND_ADDRESS); int configBindPort = configuration.getInt(BLUR_SHARD_BIND_PORT, -1); int instanceBindPort = configBindPort + serverIndex; if (configBindPort == 0) { instanceBindPort = 0;/*from w ww . ja va 2 s . c o m*/ } TServerTransport serverTransport = ThriftServer.getTServerTransport(bindAddress, instanceBindPort, configuration); instanceBindPort = ThriftServer.getBindingPort(serverTransport); Set<Entry<String, String>> set = configuration.getProperties().entrySet(); for (Entry<String, String> e : set) { String key = e.getKey(); String value = e.getValue(); if (value == null || value.isEmpty()) { continue; } if (key.startsWith("blur.shard.buffercache.")) { int index = key.lastIndexOf('.'); int bufferSize = Integer.parseInt(key.substring(index + 1)); long amount = Long.parseLong(e.getValue()); BufferStore.initNewBuffer(bufferSize, amount); } } final BlockCacheDirectoryFactory blockCacheDirectoryFactory; // Alternate BlockCacheDirectoryFactory support currently disabled in 0.2.0, // look for it in 0.2.1 String blockCacheVersion = configuration.get(BLUR_SHARD_BLOCK_CACHE_VERSION, "v2"); long totalNumberOfBytes = configuration.getLong(BLUR_SHARD_BLOCK_CACHE_TOTAL_SIZE, VM.maxDirectMemory() - _64MB); if (blockCacheVersion.equals("v1")) { blockCacheDirectoryFactory = new BlockCacheDirectoryFactoryV1(configuration, totalNumberOfBytes); } else if (blockCacheVersion.equals("v2")) { blockCacheDirectoryFactory = new BlockCacheDirectoryFactoryV2(configuration, totalNumberOfBytes); } else { throw new RuntimeException("Unknown block cache version [" + blockCacheVersion + "] can be [v1,v2]"); } LOG.info("Shard Server using index [{0}] bind address [{1}]", serverIndex, bindAddress + ":" + instanceBindPort); String nodeNameHostName = getNodeName(configuration, BLUR_SHARD_HOSTNAME); String nodeName = nodeNameHostName + ":" + instanceBindPort; configuration.set(BLUR_NODENAME, nodeName); BlurQueryChecker queryChecker = new BlurQueryChecker(configuration); String cluster = configuration.get(BLUR_CLUSTER_NAME, BLUR_CLUSTER); final ZooKeeper zooKeeper = setupZookeeper(configuration, cluster); final ZookeeperClusterStatus clusterStatus = new ZookeeperClusterStatus(zooKeeper, configuration, config); BlurFilterCache filterCache = getFilterCache(configuration); DistributedLayoutFactory distributedLayoutFactory = DistributedLayoutFactoryImpl .getDistributedLayoutFactory(configuration, cluster, zooKeeper); long requestCacheSize = configuration.getLong(BLUR_SHARD_REQUEST_CACHE_SIZE, 10000000); final ThriftCache thriftCache = new ThriftCache(requestCacheSize); long safeModeDelay = configuration.getLong(BLUR_SHARD_SAFEMODEDELAY, 60000); int shardOpenerThreadCount = configuration.getInt(BLUR_SHARD_OPENER_THREAD_COUNT, 16); int maxMergeThreads = configuration.getInt(BLUR_SHARD_MERGE_THREAD_COUNT, 3); int minimumNumberOfNodesBeforeExitingSafeMode = configuration .getInt(BLUR_SHARD_SERVER_MINIMUM_BEFORE_SAFEMODE_EXIT, 0); int internalSearchThreads = configuration.getInt(BLUR_SHARD_INTERNAL_SEARCH_THREAD_COUNT, 16); final Timer hdfsKeyValueTimer = new Timer("HDFS KV Store", true); final Timer indexImporterTimer = new Timer("IndexImporter", true); final Timer indexBulkTimer = new Timer("BulkIndex", true); long smallMergeThreshold = configuration.getLong(BLUR_SHARD_SMALL_MERGE_THRESHOLD, 128 * 1000 * 1000); SequentialReadControl sequentialReadControl = new SequentialReadControl(configuration); final DistributedIndexServer indexServer = new DistributedIndexServer(config, zooKeeper, clusterStatus, filterCache, blockCacheDirectoryFactory, distributedLayoutFactory, cluster, nodeName, safeModeDelay, shardOpenerThreadCount, maxMergeThreads, internalSearchThreads, minimumNumberOfNodesBeforeExitingSafeMode, hdfsKeyValueTimer, indexImporterTimer, smallMergeThreshold, indexBulkTimer, thriftCache, sequentialReadControl); BooleanQuery.setMaxClauseCount(configuration.getInt(BLUR_MAX_CLAUSE_COUNT, 1024)); int maxHeapPerRowFetch = configuration.getInt(BLUR_MAX_HEAP_PER_ROW_FETCH, 10000000); int remoteFetchCount = configuration.getInt(BLUR_CONTROLLER_REMOTE_FETCH_COUNT, 100); int fetchCount = configuration.getInt(BLUR_SHARD_FETCHCOUNT, 110); if (fetchCount + 1 <= remoteFetchCount) { LOG.warn("[" + BLUR_SHARD_FETCHCOUNT + "] [" + fetchCount + "] is equal to or less than [" + BLUR_CONTROLLER_REMOTE_FETCH_COUNT + "] [" + remoteFetchCount + "], should be at least 1 greater."); } int indexManagerThreadCount = configuration.getInt(BLUR_INDEXMANAGER_SEARCH_THREAD_COUNT, 32); int mutateThreadCount = configuration.getInt(BLUR_INDEXMANAGER_MUTATE_THREAD_COUNT, 32); int facetThreadCount = configuration.getInt(BLUR_INDEXMANAGER_FACET_THREAD_COUNT, 16); long statusCleanupTimerDelay = TimeUnit.SECONDS.toMillis(10); int cacheSize = configuration.getInt(BLUR_SHARD_DEEP_PAGING_CACHE_SIZE, 1000); DeepPagingCache deepPagingCache = new DeepPagingCache(cacheSize); MemoryAllocationWatcher memoryAllocationWatcher = new MemoryAllocationWatcher() { @Override public <T, E extends Exception> T run(Watcher<T, E> w) throws E { return w.run(); } }; final IndexManager indexManager = new IndexManager(indexServer, clusterStatus, filterCache, maxHeapPerRowFetch, fetchCount, indexManagerThreadCount, mutateThreadCount, statusCleanupTimerDelay, facetThreadCount, deepPagingCache, memoryAllocationWatcher); File tmpPath = getTmpPath(configuration); int numberOfShardWorkerCommandThreads = configuration.getInt(BLUR_SHARD_COMMAND_WORKER_THREADS, 16); int numberOfShardDriverCommandThreads = configuration.getInt(BLUR_SHARD_COMMAND_DRIVER_THREADS, 16); String commandPath = configuration.get(BLUR_COMMAND_LIB_PATH, getCommandLibPath()); if (commandPath != null) { LOG.info("Command Path was set to [{0}].", commandPath); } else { LOG.info("Command Path was not set."); } final ShardCommandManager commandManager = new ShardCommandManager(indexServer, tmpPath, commandPath, numberOfShardWorkerCommandThreads, numberOfShardDriverCommandThreads, Connection.DEFAULT_TIMEOUT, config); clusterStatus.registerActionOnTableStateChange(new Action() { @Override public void action() { thriftCache.clear(); } }); final BlurShardServer shardServer = new BlurShardServer(); shardServer.setNodeName(nodeName); shardServer.setCommandManager(commandManager); shardServer.setIndexServer(indexServer); shardServer.setIndexManager(indexManager); shardServer.setZookeeper(zooKeeper); shardServer.setClusterStatus(clusterStatus); shardServer.setQueryChecker(queryChecker); shardServer.setMaxRecordsPerRowFetchRequest( configuration.getInt(BLUR_MAX_RECORDS_PER_ROW_FETCH_REQUEST, 1000)); shardServer.setConfiguration(configuration); shardServer.init(); final TraceStorage traceStorage = setupTraceStorage(configuration, config); Trace.setStorage(traceStorage); Trace.setNodeName(nodeName); List<ServerSecurityFilter> serverSecurity = getServerSecurityList(configuration, ServerSecurityFilterFactory.ServerType.SHARD); Iface iface = new ThriftCacheServer(configuration, shardServer, indexServer, thriftCache); iface = BlurUtil.wrapFilteredBlurServer(configuration, iface, true); iface = ServerSecurityUtil.applySecurity(iface, serverSecurity, true); iface = BlurUtil.recordMethodCallsAndAverageTimes(iface, Iface.class, false); iface = BlurUtil.runWithUser(iface, false); iface = BlurUtil.runTrace(iface, false); iface = BlurUtil.lastChanceErrorHandling(iface, Iface.class); int configGuiPort = Integer.parseInt(configuration.get(BLUR_GUI_SHARD_PORT)); int instanceGuiPort = configGuiPort + serverIndex; if (configGuiPort == 0) { instanceGuiPort = 0; } final HttpJettyServer httpServer; if (configGuiPort >= 0) { httpServer = new HttpJettyServer(HttpJettyServer.class, instanceGuiPort); int port = httpServer.getLocalPort(); configuration.setInt(BLUR_HTTP_STATUS_RUNNING_PORT, port); } else { httpServer = null; } if (httpServer != null) { WebAppContext context = httpServer.getContext(); context.addServlet( new ServletHolder( new TServlet(new Blur.Processor<Blur.Iface>(iface), new TJSONProtocol.Factory())), "/blur"); if (enableJsonReporter) { JSONReporter.enable("json-reporter", 1, TimeUnit.SECONDS, 60); } } int threadCount = configuration.getInt(BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT, 32); ShardServerEventHandler eventHandler = new ShardServerEventHandler(); final ThriftBlurShardServer server = new ThriftBlurShardServer(); server.setNodeName(nodeName); server.setServerTransport(serverTransport); server.setThreadCount(threadCount); server.setIface(iface); server.setEventHandler(eventHandler); server.setAcceptQueueSizePerThread(configuration.getInt(BLUR_SHARD_THRIFT_ACCEPT_QUEUE_SIZE_PER_THREAD, 4)); server.setMaxReadBufferBytes( configuration.getLong(BLUR_SHARD_THRIFT_MAX_READ_BUFFER_BYTES, Long.MAX_VALUE)); server.setSelectorThreads(configuration.getInt(BLUR_SHARD_THRIFT_SELECTOR_THREADS, 2)); server.setMaxFrameSize( configuration.getInt(BLUR_THRIFT_MAX_FRAME_SIZE, BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE)); server.setConfiguration(configuration); // This will shutdown the server when the correct path is set in zk BlurShutdown shutdown = new BlurShutdown() { @Override public void shutdown() { ThreadWatcher threadWatcher = ThreadWatcher.instance(); quietClose(makeCloseable(hdfsKeyValueTimer), makeCloseable(indexImporterTimer), makeCloseable(indexBulkTimer), blockCacheDirectoryFactory, commandManager, traceStorage, server, shardServer, indexManager, indexServer, threadWatcher, clusterStatus, zooKeeper, httpServer); } }; server.setShutdown(shutdown); new BlurServerShutDown().register(shutdown, zooKeeper); return server; }
From source file:org.apache.jackrabbit.core.query.lucene.JahiaSearchIndex.java
License:Open Source License
public void setMaxClauseCount(int maxClauseCount) { this.maxClauseCount = maxClauseCount; BooleanQuery.setMaxClauseCount(maxClauseCount); }