Example usage for org.apache.solr.client.solrj SolrQuery setRows

List of usage examples for org.apache.solr.client.solrj SolrQuery setRows

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrQuery setRows.

Prototype

public SolrQuery setRows(Integer rows) 

Source Link

Usage

From source file:com.databasepreservation.visualization.utils.SolrUtils.java

public static InputStream findCSV(SolrClient index, String collection, Filter filter, Sorter sorter,
        Sublist sublist, List<String> fields) throws GenericException, RequestNotValidException {
    SolrQuery query = new SolrQuery();
    query.setQuery(parseFilter(filter));
    query.setSorts(parseSorter(sorter));
    if (sublist != null) {
        query.setStart(sublist.getFirstElementIndex());
        query.setRows(sublist.getMaximumElementCount());
    }/*from  w w w . j av  a2s .  c  om*/
    query.setFields(fields.toArray(new String[0]));

    LOGGER.debug("CSV export query object: " + query.toString());
    LOGGER.debug("CSV export query: " + query.toQueryString());

    try {
        QueryRequest queryRequest = new QueryRequest(query);
        queryRequest.setResponseParser(new InputStreamResponseParser("csv"));
        QueryResponse response = queryRequest.process(index, collection);

        Object stream = response.getResponse().get("stream");
        if (stream instanceof InputStream) {
            return (InputStream) stream;
        } else {
            throw new GenericException(
                    "Result was not an input stream. Its string representation was: " + stream.toString());
        }
    } catch (SolrServerException | IOException e) {
        throw new GenericException("Could not query index", e);
    }
}

From source file:com.databasepreservation.visualization.utils.SolrUtils.java

public static String getSolrQuery(Filter filter, Sorter sorter, Sublist sublist, Facets facets)
        throws GenericException, RequestNotValidException {
    SolrQuery query = new SolrQuery();
    query.setQuery(parseFilter(filter));
    // query.setSorts(parseSorter(sorter));
    query.setStart(sublist.getFirstElementIndex());
    query.setRows(sublist.getMaximumElementCount());
    // parseAndConfigureFacets(facets, query);

    return query.toQueryString();
}

From source file:com.doculibre.constellio.services.ClusteringServicesImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*w ww  . ja  v  a 2 s  . c o  m*/
public List<SimpleOrderedMap<Object>> cluster(SimpleSearch simpleSearch, CollectionFacet facet, int start,
        int row, ConstellioUser user) {
    //      String luceneQuery = simpleSearch.getLuceneQuery();
    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    String solrServerName = simpleSearch.getCollectionName();
    RecordCollection collection = collectionServices.get(solrServerName);

    //Remarque useDismax est  false car nous allons utiliser le type de requete "/clustering"
    //         donc pas besoin d'ajouter les paramtres necessaires  dismax
    SolrQuery query = SearchServicesImpl.toSolrQuery(simpleSearch, false, true, true);
    query.setRequestHandler("/clustering");

    query.setParam(ClusteringComponent.COMPONENT_NAME, Boolean.TRUE);
    query.setParam(ClusteringParams.USE_COLLECTION, facet.isClusteringUseCollection());
    query.setParam(ClusteringParams.USE_SEARCH_RESULTS, facet.isClusteringUseSearchResults());
    query.setParam(ClusteringParams.USE_DOC_SET, facet.isClusteringUseDocSet());
    query.setParam(ClusteringParams.ENGINE_NAME, facet.getClusteringEngine());

    //The maximum number of labels to produce
    query.setParam(CarrotParams.NUM_DESCRIPTIONS, "" + maxClusters);
    //      query.setParam(CarrotParams.NUM_DESCRIPTIONS, "" + facet.getCarrotNumDescriptions());

    query.setParam(CarrotParams.OUTPUT_SUB_CLUSTERS, facet.isCarrotOutputSubclusters());
    query.setParam(ConstellioSolrQueryParams.LUCENE_QUERY, simpleSearch.getLuceneQuery());
    query.setParam(ConstellioSolrQueryParams.COLLECTION_NAME, simpleSearch.getCollectionName());
    query.setParam(ConstellioSolrQueryParams.SIMPLE_SEARCH, simpleSearch.toSimpleParams().toString());
    if (user != null) {
        query.setParam(ConstellioSolrQueryParams.USER_ID, "" + user.getId());
    }

    //If true, then the snippet field (if no snippet field, then the title field) will be highlighted and the highlighted text will be used for the snippet. 
    query.setParam(CarrotParams.PRODUCE_SUMMARY, facet.isCarrotProduceSummary());
    if (facet.getCarrotTitleField() != null) {
        IndexField indexField = facet.getCarrotTitleField();
        query.setParam(CarrotParams.TITLE_FIELD_NAME, indexField.getName());
    }
    if (facet.getCarrotUrlField() != null) {
        IndexField indexField = facet.getCarrotUrlField();
        query.setParam(CarrotParams.URL_FIELD_NAME, indexField.getName());
    }
    if (facet.getCarrotSnippetField() != null) {
        IndexField indexField = facet.getCarrotSnippetField();
        query.setParam(CarrotParams.SNIPPET_FIELD_NAME, indexField.getName());
    }

    // Requte Lucene
    //      query.setQuery(luceneQuery);

    // nb rsultats par page
    query.setRows(row);

    // page de dbut
    query.setStart(start);
    //Les resultats ne vont pas etre affichs
    /*query.setHighlight(true);
    query.setHighlightFragsize(100);
    query.setHighlightSnippets(2);*/

    if (collection.isOpenSearch()) {
        query.setParam("openSearchURL", collection.getOpenSearchURL());
    }

    SolrServer server = SolrCoreContext.getSolrServer(solrServerName);

    QueryResponse queryResponse;
    try {
        queryResponse = server.query(query);
    } catch (SolrServerException e) {
        throw new RuntimeException(e);
    }

    NamedList<Object> values = queryResponse.getResponse();
    Object clusters = values.get("clusters");
    return (List<SimpleOrderedMap<Object>>) clusters;
}

From source file:com.doculibre.constellio.services.FacetServicesImpl.java

License:Open Source License

public static SolrQuery toSolrQuery(SimpleSearch simpleSearch, int start, int row,
        boolean includeSingleValueFacets, boolean notIncludedOnly, List<String> customFieldFacets,
        List<String> customQueryFacets, ConstellioUser user) {
    String solrServerName = simpleSearch.getCollectionName();
    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordCollection collection = collectionServices.get(solrServerName);
    SolrServices solrServices = ConstellioSpringUtils.getSolrServices();
    Boolean usesDisMax = solrServices.usesDisMax(collection);
    SolrQuery query;
    if (!collection.isOpenSearch()) {
        query = SearchServicesImpl.toSolrQuery(simpleSearch, usesDisMax, true, includeSingleValueFacets,
                notIncludedOnly);//from  w  w w . ja  va2  s  .c  o m
    } else {
        query = SearchServicesImpl.toSolrQuery(simpleSearch, usesDisMax, false, true, false);
    }

    query.setParam(ConstellioSolrQueryParams.COLLECTION_NAME, simpleSearch.getCollectionName());
    query.setParam(ConstellioSolrQueryParams.LUCENE_QUERY,
            simpleSearch.getLuceneQuery(includeSingleValueFacets, true));
    query.setParam(ConstellioSolrQueryParams.SIMPLE_SEARCH, simpleSearch.toSimpleParams().toString());
    if (user != null) {
        query.setParam(ConstellioSolrQueryParams.USER_ID, "" + user.getId());
    }

    if (StringUtils.isEmpty(query.getQuery())) {
        query.setQuery(SimpleSearch.SEARCH_ALL);
        query.setRequestHandler("/elevate");
    }

    query.set("shards.qt", "/elevate");
    query.setRequestHandler("/elevate");

    query.setRows(row);
    query.setStart(start);
    query.setHighlight(true);
    query.setHighlightFragsize(100);
    query.setHighlightSnippets(2);

    query.setFacet(true);
    query.setFacetLimit(400);
    query.setFacetMinCount(1);

    if (collection.isOpenSearch()) {
        query.setParam("openSearchURL", collection.getOpenSearchURL());
        Locale locale = simpleSearch.getSingleSearchLocale();
        if (locale != null) {
            query.setParam("lang", locale.getLanguage());
        }
    } else {
        for (CollectionFacet collectionFacet : collection.getCollectionFacets()) {
            if (customFieldFacets == null && collectionFacet.isFieldFacet()) {
                IndexField indexField = collectionFacet.getFacetField();
                String indexFieldName = indexField.getName();
                if (!notIncludedOnly) {
                    query.addFacetField(indexFieldName);
                } else {
                    SearchedFacet searchedFacet = simpleSearch.getSearchedFacet(indexFieldName);
                    if (searchedFacet != null) {
                        if (!searchedFacet.getIncludedValues().isEmpty()) {
                            StringBuffer sbEx = new StringBuffer();
                            sbEx.append("{!ex=dt}");
                            //                                sbEx.append("{!ex=");
                            //                                boolean first = true;
                            //                                for (String includedValue : searchedFacet.getIncludedValues()) {
                            //                                    if (first) {
                            //                                        first = false;
                            //                                    } else {
                            //                                        sbEx.append(",");
                            //                                    }
                            //                                    sbEx.append(includedValue); 
                            //                                }
                            //                                sbEx.append("}");
                            //                                query.setParam("facet.field", sbEx.toString() + indexFieldName);
                            query.addFacetField(sbEx.toString() + indexFieldName);
                        } else {
                            query.addFacetField(indexFieldName);
                        }
                    }
                }
            } else if (customQueryFacets == null && collectionFacet.isQueryFacet()) {
                // Modification Rida, remplacement de collectionFacet.getLabels() par
                // collectionFacet.getLabelledValues()
                // for (I18NLabel valueLabels : collectionFacet.getLabels()) {
                for (I18NLabel valueLabels : collectionFacet.getLabelledValues()) {
                    String facetQuery = valueLabels.getKey();
                    query.addFacetQuery(facetQuery);
                }
            }
        }
        if (customFieldFacets != null) {
            for (String facetField : customFieldFacets) {
                if (!notIncludedOnly) {
                    query.addFacetField(facetField);
                } else {
                    StringBuffer sbEx = new StringBuffer();
                    sbEx.append("{!ex=dt}");
                    //                        sbEx.append("{!ex=");
                    //                        boolean first = true;
                    //                        for (String includedValue : searchedFacet.getIncludedValues()) {
                    //                            if (first) {
                    //                                first = false;
                    //                            } else {
                    //                                sbEx.append(",");
                    //                            }
                    //                            sbEx.append(includedValue); 
                    //                        }
                    //                        sbEx.append("}");
                    query.setParam("facet.field", sbEx.toString() + facetField);
                }
            }
        }

        if (customQueryFacets != null) {
            for (String facetQuery : customQueryFacets) {
                query.addFacetQuery(facetQuery);
            }
        }
    }

    return query;
}

From source file:com.doculibre.constellio.services.SearchServicesImpl.java

License:Open Source License

@Override
public QueryResponse search(SimpleSearch simpleSearch, int start, int rows, SearchParams searchParams,
        ConstellioUser user) {/*from   w  w w .  j  a v  a  2  s . c  o m*/
    QueryResponse queryResponse;

    String collectionName = simpleSearch.getCollectionName();
    if (collectionName != null) {
        RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
        RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
        RecordCollection collection = collectionServices.get(collectionName);

        SolrServices solrServices = ConstellioSpringUtils.getSolrServices();
        Boolean usesDisMax = solrServices.usesDisMax(collection);

        SolrQuery query;
        if (!collection.isOpenSearch()) {
            query = toSolrQuery(simpleSearch, usesDisMax, true, true);
        } else {
            query = toSolrQuery(simpleSearch, usesDisMax, false, true);
        }
        // displayQuery(query);

        String luceneQuery = simpleSearch.getLuceneQuery();
        query.setParam(ConstellioSolrQueryParams.LUCENE_QUERY, luceneQuery);
        query.setParam(ConstellioSolrQueryParams.SIMPLE_SEARCH, simpleSearch.toSimpleParams().toString());
        query.setParam(ConstellioSolrQueryParams.COLLECTION_NAME, collectionName);
        if (user != null) {
            query.setParam(ConstellioSolrQueryParams.USER_ID, "" + user.getId());
        }

        String queryString = query.getQuery();
        if (StringUtils.isEmpty(queryString)) {
            queryString = SimpleSearch.SEARCH_ALL;
        }

        List<Record> pendingExclusions = recordServices.getPendingExclusions(collection);
        while (!pendingExclusions.isEmpty()) {
            IndexingManager indexingManager = IndexingManager.get(collection);
            if (indexingManager.isActive()) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                pendingExclusions = recordServices.getPendingExclusions(collection);
            } else {
                return null;
            }
        }

        // SolrQuery query = new SolrQuery();
        query.set("collectionName", simpleSearch.getCollectionName());
        // query.setQuery(luceneQuery);

        query.set("shards.qt", "/elevate");
        query.setRequestHandler("/elevate");

        // nb rsultats par page
        query.setRows(rows);

        // page de dbut
        query.setStart(start);
        query.setHighlight(searchParams.isHighlightingEnabled());
        if (searchParams.isHighlightingEnabled()) {
            query.setHighlightFragsize(searchParams.getFragsize());
            query.setHighlightSnippets(searchParams.getSnippets());
        }

        if (simpleSearch.getSortField() != null) {
            ORDER order = SimpleSearch.SORT_DESCENDING.equals(simpleSearch.getSortOrder()) ? ORDER.desc
                    : ORDER.asc;
            IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
            IndexField indexField = indexFieldServices.get(simpleSearch.getSortField(), collection);
            if (indexField != null) {
                IndexField sortIndexField = indexFieldServices.getSortFieldOf(indexField);
                if (sortIndexField != null) {
                    query.setSort(sortIndexField.getName(), order);
                }
            }
        }

        if (collection.isOpenSearch()) {
            query.setParam("openSearchURL", collection.getOpenSearchURL());
            Locale locale = simpleSearch.getSingleSearchLocale();
            if (locale != null) {
                query.setParam("lang", locale.getLanguage());
            }
        }

        if (searchParams.getHighlightedFields() == null) {
            IndexField defaultSearchField = collection.getDefaultSearchIndexField();
            query.addHighlightField(defaultSearchField.getName());
            for (CopyField copyFieldDest : defaultSearchField.getCopyFieldsDest()) {
                IndexField copyIndexFieldSource = copyFieldDest.getIndexFieldSource();
                if (copyIndexFieldSource != null && !copyIndexFieldSource.isTitleField()
                        && copyIndexFieldSource.isHighlighted()) {
                    query.addHighlightField(copyIndexFieldSource.getName());
                }
            }
            IndexField titleField = collection.getTitleIndexField();
            if (titleField != null && titleField.isHighlighted()) {
                query.addHighlightField(titleField.getName());
            }
        } else {
            for (String highlightedField : searchParams.getHighlightedFields()) {
                IndexField field = collection.getIndexField(highlightedField);
                if (field != null) {
                    query.addHighlightField(highlightedField);
                }
            }
        }
        SolrServer server = SolrCoreContext.getSolrServer(collectionName);
        if (server != null) {
            try {
                // displayQuery(query);
                queryResponse = server.query(query);
            } catch (SolrServerException e) {
                queryResponse = null;
            }
        } else {
            queryResponse = null;
        }

        //            if (queryResponse != null && !collection.isOpenSearch()) {
        //                StatsCompiler statCompiler = StatsCompiler.getInstance();
        //                try {
        //                    statCompiler.saveStats(collectionName, SolrLogContext.getStatsSolrServer(),
        //                        SolrLogContext.getStatsCompileSolrServer(), queryResponse, luceneQuery);
        //                } catch (SolrServerException e) {
        //                    throw new RuntimeException(e);
        //                } catch (IOException e) {
        //                    throw new RuntimeException(e);
        //                }
        //            }

    } else {
        queryResponse = null;
    }

    // improveQueryResponse(collectionName, queryResponse);
    // System.out.println("Response size" + queryResponse.getResults().getNumFound());
    return queryResponse;
}

From source file:com.doculibre.constellio.services.StatusServicesImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*www .j a v  a  2  s .co  m*/
public int countIndexedRecords(RecordCollection collection) {
    int count;
    SolrServices solrServices = ConstellioSpringUtils.getSolrServices();
    SolrServer solrServer = solrServices.getSolrServer(collection);
    if (solrServer != null) {
        SolrQuery query = new SolrQuery();
        query.setQuery("*:*");
        query.setStart(0);
        query.setRows(0);
        try {
            QueryResponse queryResponse = solrServer.query(query);
            count = (int) queryResponse.getResults().getNumFound();
        } catch (SolrServerException e) {
            throw new RuntimeException(e);
        }
    } else {
        count = 0;
    }
    return count;
}

From source file:com.doculibre.constellio.services.StatusServicesImpl.java

License:Open Source License

@Override
public List<Record> listLastIndexedRecords(RecordCollection collection, int maxSize) {
    List<Record> lastIndexedRecords;
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();

    String luceneQuery = SimpleSearch.SEARCH_ALL;
    SolrQuery solrQuery = new SolrQuery(luceneQuery);
    solrQuery.setRequestHandler("standard");
    solrQuery.setRows(maxSize);
    solrQuery.setSort(IndexField.LAST_INDEXED_FIELD, ORDER.desc);

    String collectionName = collection.getName();
    solrQuery.setParam(ConstellioSolrQueryParams.LUCENE_QUERY, luceneQuery);
    solrQuery.setParam(ConstellioSolrQueryParams.COLLECTION_NAME, collectionName);

    SolrServer server = SolrCoreContext.getSolrServer(collectionName);
    if (server != null && collection.getIndexField(IndexField.LAST_INDEXED_FIELD) != null) {
        try {//from w w w .  ja  v  a 2s.co m
            QueryResponse queryResponse = server.query(solrQuery);
            SolrDocumentList results = queryResponse.getResults();
            List<Number> recordIds = new ArrayList<Number>();
            for (SolrDocument result : results) {
                Long recordId = new Long(result.getFieldValue(IndexField.RECORD_ID_FIELD).toString());
                recordIds.add(recordId);
            }
            if (!recordIds.isEmpty()) {
                lastIndexedRecords = recordServices.list(recordIds, collection);
            } else {
                lastIndexedRecords = new ArrayList<Record>();
            }
        } catch (SolrServerException e) {
            throw new RuntimeException(e);
        }
    } else if (!collection.isSynchronizationRequired()) {
        String msg = "No SolrServer available for collection id " + collection.getId();
        LOGGER.log(Level.SEVERE, msg);
        lastIndexedRecords = new ArrayList<Record>();
    } else if (collection.getIndexField(IndexField.LAST_INDEXED_FIELD) == null) {
        String msg = "No " + IndexField.LAST_INDEXED_FIELD + " index field for collection id "
                + collection.getId();
        LOGGER.log(Level.SEVERE, msg);
        lastIndexedRecords = new ArrayList<Record>();
    } else {
        lastIndexedRecords = new ArrayList<Record>();
    }
    return lastIndexedRecords;
}

From source file:com.doculibre.constellio.servlets.SolrJExampleMain.java

License:Open Source License

/**
 * Do the query using a SolrQuery//from   w  w  w . j ava 2s . c o  m
 */
public static QueryResponse doThirdQuery(SolrServer server) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery(query);
    solrQuery.set("collectionName", myCollection);
    solrQuery.set("facet", facet);
    solrQuery.setStart(start);
    solrQuery.setRows(nbDocuments);
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsCompiler.java

License:Open Source License

public synchronized void saveStats(SimpleSearch simpleSearch, SolrServer indexJournal, SolrServer indexCompile,
        QueryResponse res) throws SolrServerException, IOException {
    String collectionName = simpleSearch.getCollectionName();
    String luceneQuery = simpleSearch.getLuceneQuery();

    GregorianCalendar calendar = new GregorianCalendar();
    Date time = new Date();
    calendar.setTime(time);/*from ww  w .  java  2  s  .c  o  m*/
    String query = luceneQuery;
    String escapedQuery = escape(query);
    long nbRes = res.getResults().getNumFound();
    long qTime = res.getQTime();
    String desplayDate = time.toString();
    String searchDate = format(time);
    String queryWithParams = simpleSearch.toSimpleParams().toString();

    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", desplayDate + query);
    doc.addField("query", query);
    doc.addField("queryWithParams", queryWithParams);
    doc.addField("nbres", "" + nbRes);
    doc.addField("qtime", "" + qTime);
    doc.addField("dateaffiche", desplayDate);
    doc.addField("date", searchDate);
    doc.addField("recherche", "recherche");
    doc.addField("collection", collectionName);

    UpdateRequest up = new UpdateRequest();
    up.setAction(ACTION.COMMIT, true, true);
    up.add(doc);

    up.process(indexJournal);

    String compileId = "collection_" + collectionName + " id_" + escapedQuery;
    SolrQuery solrQuery = new SolrQuery();
    // Requte Lucene
    solrQuery.setQuery("id:\"" + compileId + "\"");
    // nb rsultats par page
    solrQuery.setRows(15);
    // page de dbut
    solrQuery.setStart(0);
    QueryResponse qr = indexCompile.query(solrQuery);
    if (qr.getResults().getNumFound() > 0) {
        SolrDocument sd = qr.getResults().get(0);
        long freq = (Long) sd.getFieldValue("freq");
        long click = (Long) sd.getFieldValue("click");
        // indexCompile.deleteById(query);
        SolrInputDocument docCompile = new SolrInputDocument();
        docCompile.addField("id", compileId);
        docCompile.addField("query", query);
        if (!((String) sd.getFieldValue("nbres")).equals("0")) {
            ConstellioSpringUtils.getAutocompleteServices().onQueryAdd(docCompile, query);
        }
        docCompile.addField("freq", freq + 1);
        docCompile.addField("nbres", "" + nbRes);
        docCompile.addField("recherche", "recherche");
        docCompile.addField("collection", collectionName);
        if (nbRes == 0) {
            docCompile.addField("zero", "true");
        } else {
            docCompile.addField("zero", "false");
        }
        docCompile.addField("click", click);
        if (click == 0) {
            docCompile.addField("clickstr", "zero");
        } else {
            docCompile.addField("clickstr", "notzero");
        }
        up.clear();
        up.setAction(ACTION.COMMIT, true, true);
        up.add(docCompile);

        up.process(indexCompile);
    } else {
        SolrInputDocument docCompile = new SolrInputDocument();
        docCompile.addField("id", compileId);
        docCompile.addField("query", query);
        if (nbRes != 0) {
            ConstellioSpringUtils.getAutocompleteServices().onQueryAdd(docCompile, query);
        }
        docCompile.addField("freq", 1);
        docCompile.addField("recherche", "recherche");
        docCompile.addField("collection", collectionName);
        docCompile.addField("nbres", "" + nbRes);
        if (nbRes == 0) {
            docCompile.addField("zero", "true");
        } else {
            docCompile.addField("zero", "false");
        }
        docCompile.addField("click", 0);
        docCompile.addField("clickstr", "zero");
        up.clear();
        up.setAction(ACTION.COMMIT, true, true);
        up.add(docCompile);

        up.process(indexCompile);
    }
}

From source file:com.doculibre.constellio.stats.StatsCompiler.java

License:Open Source License

public synchronized void computeClick(String collectionName, SolrServer indexCompile, SimpleSearch simpleSearch)
        throws SolrServerException, IOException {
    String query = simpleSearch.getLuceneQuery();
    String escapedQuery = escape(query);
    String compileId = "collection_" + collectionName + " id_" + escapedQuery;

    SolrQuery solrQuery = new SolrQuery();
    // Requte Lucene
    solrQuery.setQuery("id:\"" + compileId + "\"");
    // nb rsultats par page
    solrQuery.setRows(15);
    // page de dbut
    solrQuery.setStart(0);/* ww  w .jav  a  2  s  .  c  o  m*/

    QueryResponse qr = indexCompile.query(solrQuery);
    if (qr.getResults().getNumFound() > 0) {
        SolrDocument sd = qr.getResults().get(0);
        long click = (Long) sd.getFieldValue("click");
        indexCompile.deleteById(escapedQuery);
        SolrInputDocument docCompile = new SolrInputDocument();
        docCompile.addField("id", compileId);
        docCompile.addField("query", query);
        if (!((String) sd.getFieldValue("nbres")).equals("0")) {
            ConstellioSpringUtils.getAutocompleteServices().onQueryAdd(docCompile, query);
        }
        docCompile.addField("freq", (Long) sd.getFieldValue("freq"));
        docCompile.addField("recherche", "recherche");
        docCompile.addField("zero", (String) sd.getFieldValue("zero"));
        docCompile.addField("nbres", (String) sd.getFieldValue("nbres"));
        docCompile.addField("click", (click + 1));
        docCompile.addField("clickstr", "notzero");
        docCompile.addField("collection", collectionName);
        UpdateRequest up = new UpdateRequest();
        up.setAction(ACTION.COMMIT, true, true);
        up.add(docCompile);
        up.process(indexCompile);
    }
}