Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrQuery.addFilterQuery()


        query.setFields(conceptUriField);
        query.setSortField(conceptUriField, SolrQuery.ORDER.asc);
        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        if (broaderField != null) {
            // find any topic with an empty broaderField
            query.addFilterQuery(" -" + broaderField + ":" + SOLR_NON_EMPTY_FIELD);
        }
        try {
            QueryResponse response = solrServer.query(query);
            if (response.getResults().size() >= MAX_ROOTS) {
                log.warn(String.format("TopicClassifier '%s' has more than %d registered topic roots."
View Full Code Here


        List<String> invalidatedFields = Arrays.asList(fieldNames);
        try {
            UpdateRequest request = new UpdateRequest();
            for (String conceptId : conceptIds) {
                SolrQuery query = new SolrQuery("*:*");
                query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
                query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
                for (SolrDocument result : solrServer.query(query).getResults()) {
                    // there should be only one (or none: tolerated)
                    SolrInputDocument newEntry = new SolrInputDocument();
                    for (String fieldName : result.getFieldNames()) {
View Full Code Here

        try {
            UpdateRequest request = new UpdateRequest();
            for (String conceptId : conceptIds) {
                SolrQuery query = new SolrQuery("*:*");
                query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
                query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
                for (SolrDocument result : solrServer.query(query).getResults()) {
                    // there should be only one (or none: tolerated)
                    SolrInputDocument newEntry = new SolrInputDocument();
                    for (String fieldName : result.getFieldNames()) {
                        if (!invalidatedFields.contains(fieldName)) {
View Full Code Here

    protected int batchOverTopics(BatchProcessor<SolrDocument> processor) throws TrainingSetException {
        // TODO: implement incremental update by using the date informations
        int processedCount = 0;
        SolrServer solrServer = getActiveSolrServer();
        SolrQuery query = new SolrQuery("*:*");
        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        String offset = null;
        boolean done = false;
        int batchSize = 1000;
        query.addSortField(conceptUriField, SolrQuery.ORDER.asc);
        query.setRows(batchSize + 1);
View Full Code Here

        query.setRows(batchSize + 1);
        try {
            while (!done) {
                // batch over all the indexed topics
                if (offset != null) {
                    query.addFilterQuery(conceptUriField + ":["
                                         + ClientUtils.escapeQueryChars(offset.toString()) + " TO *]");
                }
                QueryResponse response = solrServer.query(query);
                int count = 0;
                List<SolrDocument> batchDocuments = new ArrayList<SolrDocument>();
View Full Code Here

                                             List<String> falsePositiveExamples,
                                             List<String> falseNegativeExamples) throws ClassifierException {
        SolrServer solrServer = getActiveSolrServer();
        try {
            SolrQuery query = new SolrQuery("*:*");
            query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
            query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
            for (SolrDocument result : solrServer.query(query).getResults()) {
                // there should be only one (or none: tolerated)
                // fetch any old values to update (all metadata fields are assumed to be stored)s
                Map<String,Collection<Object>> fieldValues = new HashMap<String,Collection<Object>>();
View Full Code Here

                                             List<String> falseNegativeExamples) throws ClassifierException {
        SolrServer solrServer = getActiveSolrServer();
        try {
            SolrQuery query = new SolrQuery("*:*");
            query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
            query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
            for (SolrDocument result : solrServer.query(query).getResults()) {
                // there should be only one (or none: tolerated)
                // fetch any old values to update (all metadata fields are assumed to be stored)s
                Map<String,Collection<Object>> fieldValues = new HashMap<String,Collection<Object>>();
                for (String fieldName : result.getFieldNames()) {
View Full Code Here

    @Override
    public ClassificationReport getPerformanceEstimates(String conceptId) throws ClassifierException {

        SolrServer solrServer = getActiveSolrServer();
        SolrQuery query = new SolrQuery("*:*");
        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
        try {
            SolrDocumentList results = solrServer.query(query).getResults();
            if (results.isEmpty()) {
                throw new ClassifierException(String.format("'%s' is not a registered topic", conceptId));
View Full Code Here

    public ClassificationReport getPerformanceEstimates(String conceptId) throws ClassifierException {

        SolrServer solrServer = getActiveSolrServer();
        SolrQuery query = new SolrQuery("*:*");
        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
        try {
            SolrDocumentList results = solrServer.query(query).getResults();
            if (results.isEmpty()) {
                throw new ClassifierException(String.format("'%s' is not a registered topic", conceptId));
            }
View Full Code Here

            processedQuery += "NameLower:" + term.substring(10).toLowerCase(); //$NON-NLS-1$
          } else if (term.startsWith("Location:")) { //$NON-NLS-1${
            //Use Location as a filter query to improve query performence
            //See https://bugs.eclipse.org/bugs/show_bug.cgi?id=415874
            //processedQuery += "Location:" + term.substring(9 + req.getContextPath().length()); //$NON-NLS-1$
            query.addFilterQuery("Location:" + term.substring(9 + req.getContextPath().length()));
            continue;
          } else if (term.startsWith("Name:")) { //$NON-NLS-1$
            try {
              term = URLDecoder.decode(term, "UTF-8"); //$NON-NLS-1$
            } catch (UnsupportedEncodingException e) {
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.