Project

General

Profile

« Previous | Next » 

Revision 57157

Added by Enrico Ottonello over 4 years ago

solr 772 integration

View differences:

SolrIndexQuery.java
3 3
import java.util.List;
4 4
import java.util.Map;
5 5

  
6
import eu.dnetlib.clients.index.query.IndexQuery;
7
import eu.dnetlib.clients.index.utils.IndexFieldUtility;
8
import eu.dnetlib.cql.lucene.QueryOptions;
9
import eu.dnetlib.cql.lucene.TranslatedQuery;
10 6
import org.apache.commons.logging.Log;
11 7
import org.apache.commons.logging.LogFactory;
12 8
import org.apache.solr.client.solrj.SolrQuery;
13 9
import org.apache.solr.common.params.ModifiableSolrParams;
14 10
import org.apache.solr.common.params.SolrParams;
15 11

  
12
import eu.dnetlib.clients.index.query.IndexQuery;
13
import eu.dnetlib.clients.index.utils.IndexFieldUtility;
14
import eu.dnetlib.cql.lucene.QueryOptions;
15
import eu.dnetlib.cql.lucene.TranslatedQuery;
16

  
16 17
/**
17 18
 * The Class SolrIndexQuery.
18
 *
19
 * 
19 20
 * @author claudio, sandro
20 21
 */
21
public class SolrIndexQuery extends SolrQuery implements IndexQuery {
22
public class    SolrIndexQuery extends SolrQuery implements IndexQuery {
22 23

  
23
	/**
24
	 * The Constant serialVersionUID.
25
	 */
24
	/** The Constant serialVersionUID. */
26 25
	private static final long serialVersionUID = 1L;
27 26

  
28 27
	/**
......
32 31

  
33 32
	/**
34 33
	 * Instantiates a new solr index query.
35
	 *
36
	 * @param query   the query
37
	 * @param options the options
34
	 * 
35
	 * @param query
36
	 *            the query
37
	 * @param options
38
	 *            the options
38 39
	 */
39 40
	public SolrIndexQuery(final TranslatedQuery query, final Map<String, List<String>> options) {
40 41
		this(query.asLucene(), options);
......
46 47

  
47 48
	/**
48 49
	 * Instantiates a new solr index query.
49
	 *
50
	 * @param query   the query
51
	 * @param options the options
50
	 * 
51
	 * @param query
52
	 *            the query
53
	 * @param options
54
	 *            the options
52 55
	 */
53 56
	public SolrIndexQuery(final String query, final Map<String, List<String>> options) {
54 57
		this(query);
......
59 62

  
60 63
	/**
61 64
	 * Instantiates a new solr index query.
62
	 *
63
	 * @param query the query
65
	 * 
66
	 * @param query
67
	 *            the query
64 68
	 */
65 69
	public SolrIndexQuery(final String query) {
66 70
		super(query);
......
78 82
		return this;
79 83
	}
80 84

  
81
	@Override
82
	public IndexQuery setQueryFacetLimit(final int limit) {
83
		super.setFacetLimit(limit);
84
		return this;
85
	}
86

  
87
	@Override
88
	public IndexQuery setQueryFacetOffset(final int offset) {
89
		super.set("facet.offset", offset);
90
		return this;
91
	}
92

  
93
	@Override
94
	public IndexQuery setDSIdFilters(final List<String> dsIds) {
95
		if (!isAll(dsIds)) {
96
			for (String id : dsIds) {
97
				addFilterQuery(IndexFieldUtility.DS_ID + ":\"" + id + "\"");
98
			}
99
		}
100
		return this;
101
	}
102

  
103 85
	/**
104 86
	 * Checks if is all.
105
	 *
106
	 * @param dsIds the ds id
87
	 * 
88
	 * @param dsIds
89
	 *            the ds id
107 90
	 * @return true, if is all
108 91
	 */
109 92
	protected boolean isAll(final List<String> dsIds) {
......
112 95

  
113 96
	/**
114 97
	 * Convert our option map to a solr option parameter map.
115
	 *
116
	 * @param options input paramter map.
98
	 * 
99
	 * @param options
100
	 *            input paramter map.
117 101
	 * @return solr option parameter map.
118 102
	 */
119 103
	private SolrParams getQueryParams(final Map<String, List<String>> options) {
......
128 112

  
129 113
	/**
130 114
	 * Sets the query options.
131
	 *
132
	 * @param options the options.
115
	 * 
116
	 * @param options
117
	 *            the options.
133 118
	 */
134 119
	private void setCqlParams(final QueryOptions options) {
135 120
		if (options != null) {
136 121
			if (options.getSort() != null) {
137
				super.addSort(options.getSort().getField(), ORDER.valueOf(options.getSort().getMode().name()));
122
				super.addSort(options.getSort().getField(), SolrQuery.ORDER.valueOf(options.getSort().getMode().name()));
138 123
			}
139 124
		}
140 125
	}

Also available in: Unified diff