Project

General

Profile

« Previous | Next » 

Revision 55800

[maven-release-plugin] copy for tag dnet-index-solr-service-2.4.7

View differences:

modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/deploy.info
1
{ "type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-index-solr-service/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-index-solr-service" }
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/solr/feed/SolrDocumentMapperFactory.java
1
package eu.dnetlib.functionality.index.solr.feed;
2

  
3
import com.google.common.base.Function;
4
import eu.dnetlib.functionality.index.feed.DocumentMapperFactory;
5
import eu.dnetlib.functionality.index.model.Any.ValueType;
6
import eu.dnetlib.functionality.index.model.document.IndexDocument;
7
import eu.dnetlib.functionality.index.model.document.Status;
8
import eu.dnetlib.functionality.index.model.util.SolrIndexDocument;
9
import eu.dnetlib.functionality.index.utils.MetadataReference;
10
import org.springframework.beans.factory.annotation.Required;
11

  
12
import javax.xml.stream.XMLStreamException;
13
import java.util.Map;
14

  
15
/**
16
 * A factory for creating SolrDocumentMapper objects.
17
 */
18
public class SolrDocumentMapperFactory implements DocumentMapperFactory {
19

  
20
    protected static final String DNETRESULT = "result";
21
    /**
22
     * document factory used for the feed process.
23
     */
24
    private InputDocumentFactory documentFactory;
25

  
26

  
27
    private Function<String, IndexDocument> getRecordMapper(final Map<String, ValueType> schema,
28
                                                            final String dsId,
29
                                                            final String version) {
30

  
31
        return new Function<String, IndexDocument>() {
32

  
33
            @Override
34
            public IndexDocument apply(final String doc) {
35
                SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId);
36
                try {
37
                    indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT));
38
                } catch (XMLStreamException e) {
39
                    return indexDocument.setMarked();
40
                }
41
                indexDocument.setStatus(Status.OK);
42
                return indexDocument;
43
            }
44
        };
45
    }
46

  
47
    @Override
48
    public Function<String, IndexDocument> getRecordMapper(final Map<String, ValueType> schema, final MetadataReference mdRef, final String dsId, final String version, final boolean emptyResult) {
49
        if (emptyResult == false) return getRecordMapper(schema, dsId, version);
50
        else {
51
            return new Function<String, IndexDocument>() {
52

  
53
                @Override
54
                public IndexDocument apply(final String doc) {
55
                    SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId);
56
                    try {
57

  
58
                        ResultTransformer transformer = new ResultTransformer(ResultTransformer.Mode.empty) {
59
                            @Override
60
                            public String apply(String input) {
61
                                return input;
62
                            }
63
                        };
64
                        indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT, transformer));
65
                    } catch (XMLStreamException e) {
66
                        return indexDocument.setMarked();
67
                    }
68
                    indexDocument.setStatus(Status.OK);
69
                    return indexDocument;
70
                }
71
            };
72
        }
73
    }
74

  
75
    /**
76
     * Gets the document factory.
77
     *
78
     * @return the documentFactory
79
     */
80
    public InputDocumentFactory getDocumentFactory() {
81
        return documentFactory;
82
    }
83

  
84
    /**
85
     * Sets the document factory.
86
     *
87
     * @param documentFactory the documentFactory to set
88
     */
89
    @Required
90
    public void setDocumentFactory(final InputDocumentFactory documentFactory) {
91
        this.documentFactory = documentFactory;
92
    }
93

  
94
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/solr/browsing/BrowsingRow.java
1
package eu.dnetlib.functionality.index.solr.browsing;
2

  
3
import java.util.List;
4

  
5
import javax.xml.bind.annotation.XmlAccessType;
6
import javax.xml.bind.annotation.XmlAccessorType;
7
import javax.xml.bind.annotation.XmlElement;
8
import javax.xml.bind.annotation.XmlRootElement;
9

  
10
import org.springframework.beans.factory.annotation.Required;
11

  
12
import eu.dnetlib.data.provision.index.rmi.GroupResult;
13

  
14
/**
15
 *
16
 * serialization of the browsing result.
17
 *
18
 * <row> <groupresult field="facetFieldName1"> <value>facetFieldValue</value> <count>1</count> </groupresult>
19
 * 
20
 * <groupresult field="facetFieldName2"> <value>facetFieldValue</value> <count>1</count> </groupresult>
21
 * 
22
 * </row>
23
 *
24
 * @author claudio
25
 *
26
 */
27
@XmlRootElement(namespace = "", name = "row")
28
@XmlAccessorType(XmlAccessType.FIELD)
29
public class BrowsingRow {
30

  
31
	@XmlElement(name = "groupresult", required = true)
32
	private List<GroupResult> groupresult;
33

  
34
	public BrowsingRow() {}
35

  
36
	public BrowsingRow(final List<GroupResult> groupresult) {
37
		this.groupresult = groupresult;
38
	}
39

  
40
	/**
41
	 * adds a GroupResult.
42
	 *
43
	 * @param fieldName
44
	 * @param fieldValue
45
	 * @param count
46
	 */
47
	public void addBrowsingRow(final String fieldName, final String fieldValue, final int count) {
48
		groupresult.add(new GroupResult(fieldName, fieldValue, count));
49
	}
50

  
51
	@Override
52
	public boolean equals(final Object obj) {
53

  
54
		if (!(obj instanceof BrowsingRow)) return false;
55

  
56
		final BrowsingRow brws = (BrowsingRow) obj;
57

  
58
		return groupresult.equals(brws.getGroupResult());
59
	}
60

  
61
	public List<GroupResult> getGroupResult() {
62
		return groupresult;
63
	}
64

  
65
	@Required
66
	public void setGroupResult(final List<GroupResult> groupresult) {
67
		this.groupresult = groupresult;
68
	}
69

  
70
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/solr/browsing/GroupResult.java
1
package eu.dnetlib.functionality.index.solr.browsing;
2

  
3
import javax.xml.bind.annotation.XmlAttribute;
4
import javax.xml.bind.annotation.XmlRootElement;
5

  
6
import org.springframework.beans.factory.annotation.Required;
7

  
8
/**
9
 * <pre>
10
 * {@code
11
 * <groupresult field="facetFieldName">
12
 * 	<value>facetFieldValue</value>
13
 * 	<count>1</count>
14
 * </groupresult>
15
 * }
16
 * </pre>
17
 *
18
 * @author claudio
19
 *
20
 */
21
@XmlRootElement(namespace = "", name = "groupresult")
22
public class GroupResult {
23

  
24
	private String name;
25

  
26
	private String value;
27

  
28
	private int count;
29

  
30
	public GroupResult() {}
31

  
32
	/**
33
	 * Builds a groupResult.
34
	 *
35
	 * @param fieldName
36
	 * @param fieldValue
37
	 * @param count
38
	 */
39
	public GroupResult(final String name, final String value, final int count) {
40
		this.name = name;
41
		this.value = value;
42
		this.count = count;
43
	}
44

  
45
	@Override
46
	public boolean equals(final Object obj) {
47
		if (!(obj instanceof GroupResult)) return false;
48
		final GroupResult g = (GroupResult) obj;
49
		if ((this.getCount() == g.getCount()) && this.getName().equals(g.getName()) && this.getValue().equals(g.getValue())) return true;
50
		return false;
51
	}
52

  
53
	@XmlAttribute(name = "field", required = true)
54
	public String getName() {
55
		return name;
56
	}
57

  
58
	public String getValue() {
59
		return value;
60
	}
61

  
62
	public int getCount() {
63
		return count;
64
	}
65

  
66
	@Required
67
	public void setName(final String name) {
68
		this.name = name;
69
	}
70

  
71
	@Required
72
	public void setValue(final String value) {
73
		this.value = value;
74
	}
75

  
76
	@Required
77
	public void setCount(final int count) {
78
		this.count = count;
79
	}
80

  
81
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/utils/IndexSchemaFactory.java
1
package eu.dnetlib.functionality.index.utils;
2

  
3
import java.io.IOException;
4

  
5
import javax.xml.transform.Transformer;
6
import javax.xml.transform.TransformerConfigurationException;
7
import javax.xml.transform.TransformerException;
8
import javax.xml.transform.TransformerFactory;
9
import javax.xml.transform.TransformerFactoryConfigurationError;
10

  
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
13
import org.dom4j.Document;
14
import org.dom4j.DocumentException;
15
import org.dom4j.io.DocumentResult;
16
import org.dom4j.io.DocumentSource;
17
import org.dom4j.io.SAXReader;
18
import org.springframework.beans.factory.annotation.Required;
19
import org.springframework.core.io.Resource;
20

  
21
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
22

  
23
public class IndexSchemaFactory {
24

  
25
	private static final Log log = LogFactory.getLog(IndexSchemaFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
26

  
27
	private final static String TEXT_FIELD_TYPE = "textFieldType";
28

  
29
	private Resource schemaTemplate;
30

  
31
	private String textFieldType;
32

  
33
	/**
34
	 * Transformer used to get the index schema.
35
	 */
36
	private Transformer transformer;
37

  
38
	public void init() throws TransformerConfigurationException, TransformerFactoryConfigurationError, DocumentException, IOException {
39

  
40
		transformer = TransformerFactory.newInstance().newTransformer(new DocumentSource(new SAXReader().read(getSchemaTemplate().getInputStream())));
41
		transformer.setParameter(TEXT_FIELD_TYPE, getTextFieldType());
42
	}
43

  
44
	/**
45
	 * @param docIn
46
	 *            input document
47
	 * @return the application of the schemaXslt transformation to the docIn document
48
	 * @throws IndexServiceException
49
	 */
50
	public String getSchema(final Document fields) throws IndexServiceException {
51

  
52
		log.debug("default field type: " + getTextFieldType());
53
		log.debug("building schema from fields: \n" + fields.asXML() + "\n");
54

  
55
		final DocumentResult result = new DocumentResult();
56
		try {
57
			transformer.transform(new DocumentSource(fields), result);
58
			String xml = result.getDocument().asXML();
59

  
60
			log.debug("new index schema:\n" + xml);
61

  
62
			return xml;
63
		} catch (TransformerException e) {
64
			throw new IndexServiceException(e);
65
		}
66
	}
67

  
68
	@Required
69
	public void setSchemaTemplate(final Resource schemaTemplate) {
70
		this.schemaTemplate = schemaTemplate;
71
	}
72

  
73
	public Resource getSchemaTemplate() {
74
		return schemaTemplate;
75
	}
76

  
77
	@Required
78
	public void setTextFieldType(final String textFieldType) {
79
		this.textFieldType = textFieldType;
80
	}
81

  
82
	public String getTextFieldType() {
83
		return textFieldType;
84
	}
85

  
86
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/utils/IndexConfigFactory.java
1
package eu.dnetlib.functionality.index.utils;
2

  
3
import java.util.Map;
4
import java.util.Map.Entry;
5

  
6
import com.google.common.collect.Maps;
7
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
8
import org.antlr.stringtemplate.StringTemplate;
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.springframework.beans.factory.annotation.Required;
12

  
13
public class IndexConfigFactory {
14

  
15
	private static final Log log = LogFactory.getLog(IndexConfigFactory.class); // NOPMD
16
																				// by
17
																				// marko
18
																				// on
19
																				// 11/24/08
20
																				// 5:02
21
																				// PM
22

  
23
	public enum CONFIG_PARAMS {
24
		// TODO replace with actual values
25
		luceneMatchVersion;
26

  
27
		static boolean isValid(final String v) {
28
			try {
29
				CONFIG_PARAMS.valueOf(v);
30
				return true;
31
			} catch (Throwable e) {
32
				return false;
33
			}
34
		}
35
	};
36

  
37
	/**
38
	 * Index configuration template.
39
	 */
40
	private StringTemplate solrConfig;
41

  
42
	/**
43
	 * @param params
44
	 *            input document
45
	 * @return the application of the schemaXslt transformation to the docIn
46
	 *         document
47
	 * @throws IndexServiceException
48
	 */
49
	public String getConfig(final Map<String, String> params)
50
			throws IndexServiceException {
51
		final StringTemplate conf = new StringTemplate(getSolrConfig()
52
				.getTemplate());
53
		for (Entry<String, String> e : filter(params).entrySet()) {
54
			log.debug("setting conf property [" + e.getKey() + ":"
55
					+ e.getValue() + "]");
56
			conf.setAttribute(e.getKey(), e.getValue());
57
		}
58
		return conf.toString();
59
	}
60

  
61
	private Map<String, String> filter(final Map<String, String> params) {
62
		return Maps.filterKeys(params, input -> CONFIG_PARAMS.isValid(input));
63
	}
64

  
65
	public StringTemplate getSolrConfig() {
66
		return solrConfig;
67
	}
68

  
69
	@Required
70
	public void setSolrConfig(final StringTemplate solrConfig) {
71
		this.solrConfig = solrConfig;
72
	}
73

  
74
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/utils/ZkUtils.java
1
package eu.dnetlib.functionality.index.utils;
2

  
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.util.Map;
6
import java.util.Map.Entry;
7

  
8
import org.apache.commons.io.IOUtils;
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.apache.solr.common.cloud.SolrZkClient;
12
import org.apache.zookeeper.CreateMode;
13
import org.apache.zookeeper.KeeperException;
14
import org.dom4j.Document;
15
import org.springframework.beans.factory.annotation.Autowired;
16
import org.springframework.beans.factory.annotation.Required;
17
import org.springframework.core.io.Resource;
18
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
19

  
20
import com.google.common.collect.Maps;
21

  
22
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
23

  
24
/**
25
 * The Class ZkUtils.
26
 */
27
public class ZkUtils {
28

  
29
	/**
30
	 * The log.
31
	 */
32
	private static final Log log = LogFactory.getLog(ZkUtils.class); // NOPMD by marko on 11/24/08 5:02 PM
33

  
34
	/** The Constant CONFIGS_PATH. */
35
	private static final String CONFIGS_PATH = "/configs";
36

  
37
	/** The schema factory. */
38
	@Autowired
39
	private IndexSchemaFactory schemaFactory;
40

  
41
	/** The config factory. */
42
	private IndexConfigFactory configFactory;
43

  
44
	/** The static configuration classpath. */
45
	private String staticConfigurationClasspath;
46

  
47
	/**
48
	 * Upload zookeper config.
49
	 * 
50
	 * @param zkClient
51
	 *            the zk client
52
	 * @param coreName
53
	 *            the core name
54
	 * @param fields
55
	 *            the fields
56
	 * @param params
57
	 *            the params
58
	 * @param overwrite
59
	 *            the overwrite
60
	 */
61
	public void uploadZookeperConfig(final SolrZkClient zkClient,
62
			final String coreName,
63
			final Document fields,
64
			final Map<String, String> params,
65
			final boolean overwrite) {
66

  
67
		final String basepath = CONFIGS_PATH + "/" + coreName;
68

  
69
		log.info("uploading solr configuration to ZK for index collection: " + coreName);
70

  
71
		try {
72
			if (overwrite && zkClient.getSolrZooKeeper().exists(basepath, false) != null) {
73
				log.info("cleanup ZK configuration: " + coreName);
74
				for (String child : zkClient.getSolrZooKeeper().getChildren(basepath, false)) {
75
					final String path = basepath + "/" + child;
76
					log.debug("cleanup ZK file: " + path);
77
					zkClient.delete(path, -1, true);
78
				}
79
				zkClient.delete(basepath, -1, true);
80
			}
81
			if (!zkClient.exists(basepath, true)) {
82
				log.info("upload ZK configuration: " + coreName);
83
				zkClient.makePath(basepath, true);
84
				uploadConfiguration(zkClient, basepath, buildConfiguration(coreName, fields, params));
85
			}
86
			log.info("upload ZK configuration complete");
87
		} catch (Exception e) {
88
			log.error("unable to upload solr configuration", e);
89
		}
90
	}
91

  
92
	/**
93
	 * Builds the configuration.
94
	 * 
95
	 * @param indexName
96
	 *            the index name
97
	 * @param fields
98
	 *            the fields
99
	 * @param params
100
	 *            the params
101
	 * @return the map
102
	 * @throws IndexServiceException
103
	 *             the index service exception
104
	 */
105
	private Map<String, byte[]> buildConfiguration(final String indexName, final Document fields, final Map<String, String> params)
106
			throws IndexServiceException {
107

  
108
		Map<String, byte[]> res = Maps.newHashMap();
109

  
110
		try {
111
			log.debug("adding schema.xml to the resource map");
112
			res.put("schema.xml", schemaFactory.getSchema(fields).getBytes());
113
			
114
			res.put("solrconfig.xml", configFactory.getConfig(params).getBytes());
115
			log.debug("adding solrconfig.xml to the resource map");
116
			PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
117
			Resource[] resources = resolver.getResources(getStaticConfigurationClasspath());
118

  
119
			for (Resource r : resources) {
120
				InputStream is = r.getInputStream();
121
				if ((r.getFilename() != null) && !r.getFilename().isEmpty()) {
122
				    res.put(r.getFilename(), IOUtils.toByteArray(is));
123
				    log.debug("adding " + r.getFilename() +" to the resource map");
124
				    is.close();
125
				}
126
			}
127
			return res;
128
		} catch (Throwable e) {
129
			throw new IndexServiceException("failed to build configuration", e);
130
		}
131
	}
132

  
133
	/**
134
	 * Upload configuration.
135
	 * 
136
	 * @param zkClient
137
	 *            the zk client
138
	 * @param basePath
139
	 *            the base path
140
	 * @param resources
141
	 *            the resources
142
	 * @throws KeeperException
143
	 *             the keeper exception
144
	 * @throws InterruptedException
145
	 *             the interrupted exception
146
	 * @throws IOException
147
	 *             Signals that an I/O exception has occurred.
148
	 */
149
	private void uploadConfiguration(final SolrZkClient zkClient, final String basePath, final Map<String, byte[]> resources) throws KeeperException,
150
			InterruptedException, IOException {
151

  
152
		if (!zkClient.exists(basePath, true)) {
153
			zkClient.makePath(basePath, true);
154
		}
155

  
156
		for (final Entry<String, byte[]> e : resources.entrySet()) {
157
			String path = basePath + "/" + e.getKey();
158
			log.debug("upload ZK configuration: " + path);
159
			zkClient.create(path, e.getValue(), CreateMode.PERSISTENT, true);
160
		}
161
	}
162

  
163
	/**
164
	 * Gets the config factory.
165
	 * 
166
	 * @return the config factory
167
	 */
168
	public IndexConfigFactory getConfigFactory() {
169
		return configFactory;
170
	}
171

  
172
	/**
173
	 * Sets the config factory.
174
	 * 
175
	 * @param configFactory
176
	 *            the new config factory
177
	 */
178
	@Required
179
	public void setConfigFactory(final IndexConfigFactory configFactory) {
180
		this.configFactory = configFactory;
181
	}
182

  
183
	/**
184
	 * Gets the static configuration classpath.
185
	 * 
186
	 * @return the static configuration classpath
187
	 */
188
	public String getStaticConfigurationClasspath() {
189
		return staticConfigurationClasspath;
190
	}
191

  
192
	/**
193
	 * Sets the static configuration classpath.
194
	 * 
195
	 * @param staticConfigurationClasspath
196
	 *            the new static configuration classpath
197
	 */
198
	@Required
199
	public void setStaticConfigurationClasspath(final String staticConfigurationClasspath) {
200
		this.staticConfigurationClasspath = staticConfigurationClasspath;
201
	}
202

  
203
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/utils/RemoteSolrAdministrator.java
1
package eu.dnetlib.functionality.index.utils;
2

  
3
import java.io.IOException;
4
import java.util.Map;
5

  
6
import com.google.common.collect.Maps;
7
import com.google.gson.JsonElement;
8
import com.google.gson.JsonObject;
9
import com.google.gson.JsonParser;
10
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
11
import eu.dnetlib.functionality.index.model.Any.ValueType;
12
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
14
import org.apache.http.HttpResponse;
15
import org.apache.http.client.HttpClient;
16
import org.apache.http.client.methods.HttpGet;
17
import org.apache.solr.client.solrj.SolrClient;
18
import org.apache.solr.client.solrj.SolrServerException;
19
import org.apache.solr.client.solrj.impl.CloudSolrClient;
20
import org.apache.solr.client.solrj.request.LukeRequest;
21
import org.apache.solr.client.solrj.response.LukeResponse;
22
import org.apache.solr.client.solrj.response.LukeResponse.FieldInfo;
23
import org.apache.solr.client.solrj.response.SolrPingResponse;
24
import org.apache.solr.common.cloud.SolrZkClient;
25
import org.apache.zookeeper.Watcher;
26
import org.apache.zookeeper.data.Stat;
27
import org.springframework.beans.factory.annotation.Required;
28

  
29
public class RemoteSolrAdministrator {
30

  
31
	/**
32
	 * The log.
33
	 */
34
	private static final Log log = LogFactory.getLog(RemoteSolrAdministrator.class);
35

  
36
	/** The create url request. */
37
	private static String createURLRequest = "http://%s:%s/solr/admin/collections?action=CREATE&name=%s&numShards=%s&replicationFactor=%s&maxShardsPerNode=%s&collection.configName=%s";
38

  
39
	/** The create url request. */
40
	private static String reloadURLRequest = "http://%s:%s/solr/admin/collections?action=RELOAD&name=%s";
41

  
42
	/** The http client. */
43
	private HttpClient httpClient;
44

  
45
	protected Map<String, Map<String, ValueType>> cachedSchema;
46

  
47
	public RemoteSolrAdministrator() {
48
		this.cachedSchema = Maps.newHashMap();
49
	}
50

  
51
	public boolean createSolrIndex(final String host,
52
			final String port,
53
			final String collectionName,
54
			final String numShard,
55
			final String replicationFactor,
56
			final String maxShardsPerNode,
57
		final String collectionConfigName) throws IndexServiceException {
58

  
59
		final String uri = generateCreateIndexRequest(host, port, collectionName, numShard, replicationFactor, maxShardsPerNode, collectionConfigName);
60
		log.info(uri);
61
		HttpGet request = new HttpGet(uri);
62
		HttpResponse response;
63
		try {
64
			response = getHttpClient().execute(request);
65

  
66
		} catch (Exception e) {
67
			throw new IndexServiceException("Unable to send request to solr server", e);
68
		} finally {
69
			request.releaseConnection();
70
		}
71
		if (response.getStatusLine().getStatusCode() != 200)
72
			throw new IndexServiceException("Error on creating index the error code from solr is" + response.toString());
73
		return false;
74
	}
75

  
76
	public boolean indexCollectionExists(final String indexCollectionId, final CloudSolrClient client) {
77

  
78
		Watcher watcher = arg0 -> {};
79
		try {
80
			// server.connect();
81
			SolrZkClient zkClient = client.getZkStateReader().getZkClient();
82
			if (!zkClient.isConnected()) {
83
				client.connect();
84
			}
85

  
86
			byte[] data = zkClient.getData("/clusterstate.json", watcher, new Stat(), true);
87
			if (data == null) return false;
88
			String jsonLine = new String(data);
89
			JsonElement jelement = new JsonParser().parse(jsonLine);
90
			JsonObject jobject = jelement.getAsJsonObject();
91
			if (jobject.has(indexCollectionId)) {
92
				client.setDefaultCollection(indexCollectionId);
93
				client.connect();
94
				SolrPingResponse status = client.ping();
95
				return (Integer) status.getResponseHeader().get("status") == 0;
96
			} else return false;
97

  
98
		} catch (Exception e) {
99
			log.error(e);
100
			return false;
101
		}
102
	}
103

  
104
	private ValueType resolveSolrTypeClassName(final String solrTypeName) {
105
		if (solrTypeName.contains("LongField")) return ValueType.LONG;
106
		else if (solrTypeName.contains("IntField")) return ValueType.LONG;
107
		else if (solrTypeName.contains("short")) return ValueType.LONG;
108
		else if (solrTypeName.contains("float")) return ValueType.DOUBLE;
109
		else if (solrTypeName.contains("double")) return ValueType.DOUBLE;
110
		else if (solrTypeName.contains("date")) return ValueType.DATETIME;
111
		else return ValueType.STRING;
112
	}
113

  
114
	public Map<String, ValueType> getFieldNamesAndTypes(final String coreName, final SolrClient client) throws IndexServiceException {
115
		try {
116
			if (cachedSchema.get(coreName) == null) {
117
				synchronized (cachedSchema) {
118
					Map<String, ValueType> schema = readFieldNamesAndTypes(coreName, client);
119
					log.info("setting cache for schema of collection: " + coreName);
120
					cachedSchema.put(coreName, schema);
121
				}
122
			}
123
			return cachedSchema.get(coreName);
124
		} catch (Exception e) {
125
			throw new IndexServiceException("Unable to get Schema for " + coreName + " exception", e);
126
		}
127
	}
128

  
129
	private Map<String, ValueType> readFieldNamesAndTypes(final String coreName, final SolrClient client) throws SolrServerException, IOException {
130
		final LukeRequest request = new LukeRequest();
131
		request.setShowSchema(true);
132
		request.setNumTerms(0);
133
		final LukeResponse response = request.process(client);
134
		final Map<String, FieldInfo> fieldInfos = response.getFieldInfo();
135
		final Map<String, LukeResponse.FieldTypeInfo> fieldTypeInfos = response.getFieldTypeInfo();
136
		final Map<String, ValueType> result = Maps.newHashMap();
137
		for (FieldInfo fieldInfo : fieldInfos.values()) {
138
			LukeResponse.FieldTypeInfo fieldTypeInfo = fieldTypeInfos.get(fieldInfo.getType());
139
			final String fieldName = fieldTypeInfo.getName().toLowerCase();
140
			final ValueType fieldType = resolveSolrTypeClassName(fieldName);
141
			result.put(fieldInfo.getName(), fieldType);
142
		}
143
		return result;
144
	}
145

  
146
	private String generateCreateIndexRequest(final String host,
147
			final String port,
148
			final String collectionName,
149
			final String numShard,
150
			final String replicationFactor,
151
			final String collectionConfigName,
152
			final String maxShardsPerNode) {
153
		return String.format(createURLRequest, host, port, collectionName, numShard, replicationFactor, maxShardsPerNode, collectionConfigName);
154
	}
155

  
156
	private String generateUpdateIndexRequest(final String host, final String port, final String collectionName) {
157
		return String.format(reloadURLRequest, host, port, collectionName);
158
	}
159

  
160
	/**
161
	 * @return the httpClient
162
	 */
163
	public HttpClient getHttpClient() {
164
		return httpClient;
165
	}
166

  
167
	/**
168
	 * @param httpClient
169
	 *            the httpClient to set
170
	 */
171
	@Required
172
	public void setHttpClient(final HttpClient httpClient) {
173
		log.info("setting http client " + httpClient.getClass());
174
		this.httpClient = httpClient;
175
	}
176

  
177
	public void reloadCollection(final String host, final String port, final String collectionName) throws IndexServiceException {
178
		log.info("creating the request of reload index " + generateUpdateIndexRequest(host, port, collectionName));
179
		HttpGet request = new HttpGet(generateUpdateIndexRequest(host, port, collectionName));
180
		HttpResponse response;
181
		try {
182
			response = httpClient.execute(request);
183
		} catch (Exception e) {
184
			throw new IndexServiceException("Unable to send request to solr server", e);
185
		} finally {
186
			request.releaseConnection();
187
		}
188
		if (response.getStatusLine().getStatusCode() != 200)
189
			throw new IndexServiceException("Error on reloading index the error code from solr is" + response.toString());
190

  
191
	}
192

  
193
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/SolrIndexServerDAO.java
1
package eu.dnetlib.functionality.index;
2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.util.Map;
6

  
7
import eu.dnetlib.functionality.cql.CqlValueTransformerMap;
8
import org.apache.commons.logging.Log;
9
import org.apache.commons.logging.LogFactory;
10

  
11
import org.apache.solr.client.solrj.impl.CloudSolrClient;
12
import org.dom4j.Document;
13
import org.dom4j.DocumentException;
14
import org.dom4j.io.SAXReader;
15
import org.springframework.beans.factory.annotation.Autowired;
16
import org.springframework.beans.factory.annotation.Required;
17

  
18
import com.google.common.collect.Maps;
19

  
20
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
21

  
22
import eu.dnetlib.functionality.index.feed.DocumentMapperFactory;
23
import eu.dnetlib.functionality.index.model.Any.ValueType;
24
import eu.dnetlib.functionality.index.query.IndexQueryFactory;
25
import eu.dnetlib.functionality.index.query.SolrIndexQueryFactory;
26
import eu.dnetlib.functionality.index.query.SolrIndexQueryResponseFactory;
27
import eu.dnetlib.functionality.index.solr.cql.SolrTypeBasedCqlValueTransformerMapFactory;
28
import eu.dnetlib.functionality.index.solr.feed.SolrDocumentMapperFactory;
29
import eu.dnetlib.functionality.index.utils.IndexConfigFactory;
30
import eu.dnetlib.functionality.index.utils.MetadataReference;
31
import eu.dnetlib.functionality.index.utils.RemoteSolrAdministrator;
32
import eu.dnetlib.functionality.index.utils.ZkUtils;
33

  
34
/**
35
 * The Class SolrIndexServerDAO.
36
 */
37
public class SolrIndexServerDAO extends AbstractBackendDescriptor implements IndexServerDAO {
38

  
39
	/**
40
	 * The log.
41
	 */
42
	private static final Log log = LogFactory.getLog(SolrIndexServerDAO.class); // NOPMD by marko on 11/24/08 5:02 PM
43

  
44
	/** The zk utils. */
45
	@Autowired
46
	private ZkUtils zkUtils;
47

  
48
	/** The query response factory. */
49
	@Autowired
50
	private SolrIndexQueryResponseFactory queryResponseFactory;
51

  
52
	@Autowired
53
	private SolrIndexQueryFactory solrIndexQueryFactory;
54

  
55
	/** The solr document mapper factory. */
56
	@Autowired
57
	private SolrDocumentMapperFactory solrDocumentMapperFactory;
58

  
59
	/** The solr administrator. */
60
	private RemoteSolrAdministrator solrAdministrator;
61

  
62
	/** The solr type based cql value transformer map. */
63
	@Autowired
64
	private SolrTypeBasedCqlValueTransformerMapFactory tMapFactory;
65

  
66
	/**
67
	 * {@inheritDoc}
68
	 * 
69
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#createIndexCollection(eu.dnetlib.functionality.index.utils.MetadataReference,
70
	 *      java.lang.String)
71
	 */
72
	@Override
73
	public void createIndexCollection(final MetadataReference mdref, final String fields) throws IndexServiceException {
74
		CloudSolrClient client = null;
75
		try {
76
			client = getClient();
77
			client.connect();
78

  
79
			if (!solrAdministrator.indexCollectionExists(mdref.toString(), client)) {
80
				Map<String, String> params = Maps.newHashMap();
81

  
82
				final Map<String, String> p = getServiceProperties();
83
				params.put("numShards", p.get("numShards"));
84
				params.put("replicationFactor", p.get("replicationFactor"));
85

  
86
				for (IndexConfigFactory.CONFIG_PARAMS param_Name : IndexConfigFactory.CONFIG_PARAMS.values()) {
87
					params.put(param_Name.toString(), p.get(param_Name.toString()));
88
				}
89

  
90
				zkUtils.uploadZookeperConfig(client.getZkStateReader().getZkClient(), mdref.toString(), parse(fields), params, true);
91
				solrAdministrator.createSolrIndex(p.get("host"), p.get("port"), mdref.toString(), p.get("numShards"), p.get("replicationFactor"),
92
						mdref.toString(), p.get("maxShardsPerNode"));
93
			}
94
			client.getZkStateReader().close();
95

  
96
		} catch (Exception e) {
97
			log.error("Error on creating IndexCollection", e);
98
			throw new IndexServiceException("Error on creating IndexCollection", e);
99
		} finally {
100
			if (client != null) {
101
				shutdown(mdref);
102
			}
103
		}
104
	}
105

  
106
	@Override
107
	public void updateIndexCollection(final MetadataReference mdRef, final Document fields) throws IndexServiceException {
108
		CloudSolrClient client = null;
109
		try {
110
			client = getClient();
111
			client.connect();
112
			Map<String, String> params = Maps.newHashMap();
113

  
114
			params.put("numShards", getServiceProperties().get("numShards"));
115
			params.put("replicationFactor", getServiceProperties().get("replicationFactor"));
116

  
117
			for (IndexConfigFactory.CONFIG_PARAMS param_Name : IndexConfigFactory.CONFIG_PARAMS.values()) {
118
				params.put(param_Name.toString(), getServiceProperties().get(param_Name.toString()));
119
			}
120

  
121
			zkUtils.uploadZookeperConfig(client.getZkStateReader().getZkClient(), mdRef.toString(), fields, params, true);
122
			client.getZkStateReader().close();
123
			shutdown(mdRef);
124
			solrAdministrator.reloadCollection(getServiceProperties().get("host"), getServiceProperties().get("port"), mdRef.toString());
125

  
126
		} catch (Exception e) {
127
			log.error("Error on updating IndexCollection", e);
128
			throw new IndexServiceException("Error on updating IndexCollection", e);
129
		} finally {
130
			if (client != null) {
131
				shutdown(mdRef);
132
			}
133
		}
134
	}
135

  
136
	/**
137
	 * Parses the fields parameter.
138
	 * 
139
	 * @param fields
140
	 *            the fields
141
	 * @return the document
142
	 * @throws IndexServiceException
143
	 *             the index service exception
144
	 */
145
	private Document parse(final String fields) throws IndexServiceException {
146
		try {
147
			return new SAXReader().read(new StringReader(fields));
148
		} catch (DocumentException e) {
149
			throw new IndexServiceException("unable to parse fields: " + fields, e);
150
		}
151
	}
152

  
153
	/**
154
	 * {@inheritDoc}
155
	 * 
156
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#getIndexCollection(eu.dnetlib.functionality.index.utils.MetadataReference)
157
	 */
158
	@Override
159
	public IndexCollection getIndexCollection(final MetadataReference mdref) throws IndexServiceException {
160
		final CloudSolrClient client = getClient(mdref);
161
		return new SolrIndexCollection(client);
162
	}
163

  
164
	/**
165
	 * {@inheritDoc}
166
	 * 
167
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#getSchema(MetadataReference)
168
	 */
169
	@Override
170
	public Map<String, ValueType> getSchema(final MetadataReference mdRef) throws IndexServiceException {
171
		CloudSolrClient client = getClient(mdRef);
172
		Map<String, ValueType> fields = solrAdministrator.getFieldNamesAndTypes(mdRef.toString(), client);
173
		shutdown(mdRef);
174
		return fields;
175
	}
176

  
177
	/**
178
	 * {@inheritDoc}
179
	 * 
180
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#getCqlValueTransformerMap(MetadataReference)
181
	 */
182
	@Override
183
	public CqlValueTransformerMap getCqlValueTransformerMap(final MetadataReference mdRef) throws IndexServiceException {
184
		return tMapFactory.getIt(getSchema(mdRef));
185
	}
186

  
187
	/**
188
	 * {@inheritDoc}
189
	 * 
190
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#getDocumentMapperFactory()
191
	 */
192
	@Override
193
	public DocumentMapperFactory getDocumentMapperFactory() throws IndexServiceException {
194
		return solrDocumentMapperFactory;
195
	}
196

  
197
	/**
198
	 * {@inheritDoc}
199
	 * 
200
	 * @see eu.dnetlib.functionality.index.IndexServerDAO#shutdown(MetadataReference)
201
	 */
202
	@Override
203
	public void shutdown(final MetadataReference mdRef) throws IndexServiceException {
204
		try {
205
			getClient(mdRef).close();
206
		} catch (IOException e) {
207
			throw new IndexServiceException(e);
208
		}
209
	}
210

  
211
	/**
212
	 * Gets a server with the default collection set according to the given mdRef.
213
	 * 
214
	 * @param mdRef
215
	 *            the md ref
216
	 * @return a server instance
217
	 * @throws IndexServiceException
218
	 *             the index service exception
219
	 */
220
	private CloudSolrClient getClient(final MetadataReference mdRef) throws IndexServiceException {
221
		CloudSolrClient server = getClient();
222
		server.setDefaultCollection(mdRef.toString());
223
		return server;
224
	}
225

  
226
	/**
227
	 * Gets the server.
228
	 * 
229
	 * @return a server instance
230
	 */
231
	private CloudSolrClient getClient() {
232
		final String address = getEndpoint().get(ADDRESS);
233
		log.info("connecting to address: " + address);
234
		return new CloudSolrClient.Builder()
235
				.withZkHost(address)
236
				.build();
237
	}
238

  
239
	/**
240
	 * Gets the solr administrator.
241
	 * 
242
	 * @return the solrAdministrator
243
	 */
244
	public RemoteSolrAdministrator getSolrAdministrator() {
245
		return solrAdministrator;
246
	}
247

  
248
	/**
249
	 * Sets the solr administrator.
250
	 * 
251
	 * @param solrAdministrator
252
	 *            the solrAdministrator to set
253
	 */
254
	@Required
255
	public void setSolrAdministrator(final RemoteSolrAdministrator solrAdministrator) {
256
		this.solrAdministrator = solrAdministrator;
257
	}
258

  
259
	@Override
260
	public IndexQueryFactory getIndexQueryFactory() {
261
		return solrIndexQueryFactory;
262
	}
263

  
264
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/java/eu/dnetlib/functionality/index/SolrIndexCollection.java
1
package eu.dnetlib.functionality.index;
2

  
3
import java.io.IOException;
4
import java.util.Collection;
5
import java.util.Iterator;
6

  
7
import org.apache.commons.lang3.StringUtils;
8
import org.apache.commons.logging.Log;
9
import org.apache.commons.logging.LogFactory;
10
import org.apache.solr.client.solrj.impl.CloudSolrClient;
11
import org.apache.solr.client.solrj.response.UpdateResponse;
12
import org.apache.solr.common.SolrInputDocument;
13

  
14
import com.google.common.base.Function;
15
import com.google.common.collect.Iterators;
16
import com.google.common.collect.Lists;
17

  
18
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
19
import eu.dnetlib.functionality.index.model.document.IndexDocument;
20
import eu.dnetlib.functionality.index.model.util.SolrIndexDocument;
21
import eu.dnetlib.functionality.index.utils.IndexFieldUtility;
22

  
23
/**
24
 * The Class SolrIndexCollection.
25
 */
26
public class SolrIndexCollection implements IndexCollection {
27

  
28
	/**
29
	 * The log.
30
	 */
31
	private static final Log log = LogFactory.getLog(SolrIndexCollection.class); // NOPMD by marko on 11/24/08 5:02 PM
32

  
33
	/** The Constant STATUS_INDEX_OK. */
34
	public static final int STATUS_INDEX_OK = 0;
35

  
36
	/** The server. */
37
	private CloudSolrClient client;
38

  
39
	private boolean shutdown = false;
40

  
41
	/**
42
	 * The Constructor.
43
	 *
44
	 * @param client
45
	 *            the client
46
	 */
47
	public SolrIndexCollection(final CloudSolrClient client) {
48
		this.client = client;
49
		client.connect();
50
	}
51

  
52
	/**
53
	 * {@inheritDoc}
54
	 *
55
	 * @see eu.dnetlib.functionality.index.IndexCollection#add(eu.dnetlib.functionality.index.model.document.IndexDocument)
56
	 */
57
	@Override
58
	public boolean add(final IndexDocument doc) throws IndexServiceException {
59
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
60
		final SolrIndexDocument solrDocument = (SolrIndexDocument) doc;
61
		try {
62
			final UpdateResponse response = client.add(solrDocument.getSolrDocument());
63
			return response.getStatus() == 0;
64
		} catch (final Exception e) {
65
			throw new IndexServiceException("Unable to add document", e);
66
		}
67
	}
68

  
69
	/**
70
	 * {@inheritDoc}
71
	 *
72
	 * @see eu.dnetlib.functionality.index.IndexCollection#addAll(java.util.Iterator)
73
	 */
74
	@Override
75
	public boolean addAll(final Iterator<IndexDocument> docs) throws IndexServiceException {
76
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
77
		final Iterator<SolrInputDocument> solrDocs = Iterators.transform(docs, new Function<IndexDocument, SolrInputDocument>() {
78

  
79
			@Override
80
			public SolrInputDocument apply(final IndexDocument doc) {
81
				final SolrIndexDocument solrDocument = (SolrIndexDocument) doc;
82
				return solrDocument.getSolrDocument();
83
			}
84
		});
85

  
86
		try {
87
			final UpdateResponse response = client.add(Lists.newArrayList(solrDocs));
88
			return response.getStatus() == 0;
89
		} catch (final Exception e) {
90
			throw new IndexServiceException("Unable to add document", e);
91
		}
92
	}
93

  
94
	/**
95
	 * {@inheritDoc}
96
	 *
97
	 * @see eu.dnetlib.functionality.index.IndexCollection#addAll(java.util.Collection)
98
	 */
99
	@Override
100
	public boolean addAll(final Collection<IndexDocument> docs) throws IndexServiceException {
101
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
102
		return addAll(docs.iterator());
103
	}
104

  
105
	/**
106
	 * {@inheritDoc}
107
	 *
108
	 * @see eu.dnetlib.functionality.index.IndexCollection#deleteIndex(java.lang.String)
109
	 */
110
	@Override
111
	public boolean deleteIndex(final String dsId) throws IndexServiceException {
112
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
113
		return doDelete(IndexFieldUtility.DS_ID + " : \"" + dsId + "\"");
114
	}
115

  
116
	/**
117
	 * {@inheritDoc}
118
	 *
119
	 * @see eu.dnetlib.functionality.index.IndexCollection#deleteByQuery(java.lang.String, java.lang.String)
120
	 */
121
	@Override
122
	public boolean deleteByQuery(final String query, final String dsId) throws IndexServiceException {
123
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
124
		if (StringUtils.isBlank(dsId)) return doDelete(query);
125
		return doDelete(query + " AND " + IndexFieldUtility.DS_ID + " : \"" + dsId + "\"");
126
	}
127

  
128
	/**
129
	 * Do delete.
130
	 *
131
	 * @param query
132
	 *            the query
133
	 * @return true, if do delete
134
	 * @throws IndexServiceException
135
	 *             the index service exception
136
	 */
137
	protected boolean doDelete(final String query) throws IndexServiceException {
138
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
139
		try {
140
			log.debug("delete by query: " + query);
141
			return client.deleteByQuery(query).getStatus() == STATUS_INDEX_OK;
142
		} catch (final Exception e) {
143
			throw new IndexServiceException("unable to run delete by query: " + query, e);
144
		}
145
	}
146

  
147
	/**
148
	 * {@inheritDoc}
149
	 *
150
	 * @see eu.dnetlib.functionality.index.IndexCollection#commit()
151
	 */
152
	@Override
153
	public boolean commit() throws IndexServiceException {
154
		if (isShutdown()) throw new IndexServiceException("Please get another SolrIndexCollection: this has been shut down");
155
		try {
156
			log.info("performing commit");
157
			final UpdateResponse rsp = client.commit();
158
			log.info(String.format("commit completed in %s, status %s", rsp.getElapsedTime(), rsp.getStatus()));
159
			return rsp.getStatus() == STATUS_INDEX_OK;
160
		} catch (final Throwable e) {
161
			throw new IndexServiceException("unable to perform index commit", e);
162
		}
163
	}
164

  
165
	@Override
166
	public void shutdown() {
167
		try {
168
			client.close();
169
		} catch (IOException e) {
170
			throw new RuntimeException(e);
171
		}
172
		shutdown = true;
173
	}
174

  
175
	public boolean isShutdown() {
176
		return shutdown;
177
	}
178

  
179
	public void setShutdown(final boolean shutdown) {
180
		this.shutdown = shutdown;
181
	}
182

  
183
}
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/resources/eu/dnetlib/functionality/index/applicationContext-index-solr-service.properties
1
service.solr.index.staticConfigurationClasspath= eu/dnetlib/functionality/index/conf/files/**
2
service.solr.index.jsonConfiguration= \
3
        {"id":"solr",\
4
        "address":"localhost:9983",\
5
        "port":"8983",\
6
        "webContext":"solr",\
7
        "numShards":"4",\
8
        "replicationFactor":"1",\
9
	    "maxShardsPerNode":"4",\
10
        "host":"localhost",\
11
        "luceneMatchVersion":"6.6.0",\
12
        "feedingShutdownTolerance":"30000",\
13
        "feedingBufferFlushThreshold":"1000",\
14
        "feedingSimulationMode":"false" }
15

  
16
service.index.solr.returnEmptyFields		= true
17
service.index.solr.schema.textfieldtype		= text_common
18
service.index.solr.nh.mdformat.enable		= true
19
service.index.solr.highlight.enable			= true
20
service.index.solr.rank.enable				= true
21
service.index.feed.repeatDelay				= 20000
22
services.mapreduce.index.solr.feed.sim.mode	= false
23
service.index.solr.document.factory			= eu.dnetlib.functionality.index.solr.feed.StreamingInputDocumentFactory
24
service.index.solr.schema.template			= classpath:/eu/dnetlib/functionality/index/conf/schemaTemplate.xslt
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/resources/eu/dnetlib/functionality/index/conf/files/protwords.txt
1
# The ASF licenses this file to You under the Apache License, Version 2.0
2
# (the "License"); you may not use this file except in compliance with
3
# the License.  You may obtain a copy of the License at
4
#
5
#     http://www.apache.org/licenses/LICENSE-2.0
6
#
7
# Unless required by applicable law or agreed to in writing, software
8
# distributed under the License is distributed on an "AS IS" BASIS,
9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
# See the License for the specific language governing permissions and
11
# limitations under the License.
12

  
13
#-----------------------------------------------------------------------
14
# Use a protected word file to protect against the stemmer reducing two
15
# unrelated words to the same base word.
16

  
17
# Some non-words that normally won't be encountered,
18
# just to test that they won't be stemmed.
19
dontstems
20
zwhacky
21

  
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/resources/eu/dnetlib/functionality/index/conf/files/stopwords.txt
1
# Licensed to the Apache Software Foundation (ASF) under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
a
16
an
17
and
18
are
19
as
20
at
21
be
22
but
23
by
24
for
25
if
26
in
27
into
28
is
29
it
30
no
31
not
32
of
33
on
34
or
35
s
36
such
37
t
38
that
39
the
40
their
41
then
42
there
43
these
44
they
45
this
46
to
47
was
48
will
49
with
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/resources/eu/dnetlib/functionality/index/conf/files/elevate.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3
 Licensed to the Apache Software Foundation (ASF) under one or more
4
 contributor license agreements.  See the NOTICE file distributed with
5
 this work for additional information regarding copyright ownership.
6
 The ASF licenses this file to You under the Apache License, Version 2.0
7
 (the "License"); you may not use this file except in compliance with
8
 the License.  You may obtain a copy of the License at
9

  
10
     http://www.apache.org/licenses/LICENSE-2.0
11

  
12
 Unless required by applicable law or agreed to in writing, software
13
 distributed under the License is distributed on an "AS IS" BASIS,
14
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 See the License for the specific language governing permissions and
16
 limitations under the License.
17
-->
18

  
19
<!-- If this file is found in the config directory, it will only be
20
     loaded once at startup.  If it is found in Solr's data
21
     directory, it will be re-loaded every commit.
22

  
23
   See http://wiki.apache.org/solr/QueryElevationComponent for more info
24

  
25
-->
26
<elevate>
27
 <!-- Query elevation examples
28
  <query text="foo bar">
29
    <doc id="1" />
30
    <doc id="2" />
31
    <doc id="3" />
32
  </query>
33

  
34
for use with techproducts example
35
 
36
  <query text="ipod">
37
    <doc id="MA147LL/A" />  put the actual ipod at the top 
38
    <doc id="IW-02" exclude="true" /> exclude this cable
39
  </query>
40
-->
41

  
42
</elevate>
modules/dnet-index-solr-service/tags/dnet-index-solr-service-2.4.7/src/main/resources/eu/dnetlib/functionality/index/conf/files/currency.xml
1
<?xml version="1.0" ?>
2
<!--
3
 Licensed to the Apache Software Foundation (ASF) under one or more
4
 contributor license agreements.  See the NOTICE file distributed with
5
 this work for additional information regarding copyright ownership.
6
 The ASF licenses this file to You under the Apache License, Version 2.0
7
 (the "License"); you may not use this file except in compliance with
8
 the License.  You may obtain a copy of the License at
9

  
10
     http://www.apache.org/licenses/LICENSE-2.0
11

  
12
 Unless required by applicable law or agreed to in writing, software
13
 distributed under the License is distributed on an "AS IS" BASIS,
14
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 See the License for the specific language governing permissions and
16
 limitations under the License.
17
-->
18

  
19
<!-- Example exchange rates file for CurrencyField type named "currency" in example schema -->
20

  
21
<currencyConfig version="1.0">
22
  <rates>
23
    <!-- Updated from http://www.exchangerate.com/ at 2011-09-27 -->
24
    <rate from="USD" to="ARS" rate="4.333871" comment="ARGENTINA Peso" />
25
    <rate from="USD" to="AUD" rate="1.025768" comment="AUSTRALIA Dollar" />
26
    <rate from="USD" to="EUR" rate="0.743676" comment="European Euro" />
27
    <rate from="USD" to="BRL" rate="1.881093" comment="BRAZIL Real" />
28
    <rate from="USD" to="CAD" rate="1.030815" comment="CANADA Dollar" />
29
    <rate from="USD" to="CLP" rate="519.0996" comment="CHILE Peso" />
30
    <rate from="USD" to="CNY" rate="6.387310" comment="CHINA Yuan" />
31
    <rate from="USD" to="CZK" rate="18.47134" comment="CZECH REP. Koruna" />
32
    <rate from="USD" to="DKK" rate="5.515436" comment="DENMARK Krone" />
33
    <rate from="USD" to="HKD" rate="7.801922" comment="HONG KONG Dollar" />
34
    <rate from="USD" to="HUF" rate="215.6169" comment="HUNGARY Forint" />
35
    <rate from="USD" to="ISK" rate="118.1280" comment="ICELAND Krona" />
36
    <rate from="USD" to="INR" rate="49.49088" comment="INDIA Rupee" />
37
    <rate from="USD" to="XDR" rate="0.641358" comment="INTNL MON. FUND SDR" />
38
    <rate from="USD" to="ILS" rate="3.709739" comment="ISRAEL Sheqel" />
39
    <rate from="USD" to="JPY" rate="76.32419" comment="JAPAN Yen" />
40
    <rate from="USD" to="KRW" rate="1169.173" comment="KOREA (SOUTH) Won" />
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff