Project

General

Profile

« Previous | Next » 

Revision 44419

fixed delete by version implementation in index service (refresh mode feeding)

View differences:

modules/dnet-data-provision-services/trunk/src/test/java/eu/dnetlib/index/utils/IndexDateUtilityTest.java
1
package eu.dnetlib.index.utils;
2

  
3
import eu.dnetlib.miscutils.datetime.DateUtils;
4
import org.apache.commons.logging.Log;
5
import org.apache.commons.logging.LogFactory;
6
import org.junit.Test;
7
import org.junit.Before;
8
import org.junit.After;
9

  
10
/**
11
 * IndexDateUtility Tester.
12
 *
13
 * @author <Authors name>
14
 * @version 1.0
15
 * @since <pre>Nov 9, 2016</pre>
16
 */
17
public class IndexDateUtilityTest {
18

  
19
	/**
20
	 * Method: getParsedDateField(final String date)
21
	 */
22
	@Test
23
	public void testGetParsedDateField() throws Exception {
24
		final String version = DateUtils.now_ISO8601();
25
		final String parsed = IndexDateUtility.getParsedDateField(version);
26

  
27
		System.out.println(String.format("v: '%s' p: '%s'", version, parsed));
28
	}
29

  
30
} 
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/actors/IndexFeedActorImpl.java
7 7

  
8 8
import eu.dnetlib.clients.index.model.document.IndexDocument;
9 9
import eu.dnetlib.clients.index.utils.IndexFieldUtility;
10
import eu.dnetlib.index.utils.IndexDateUtility;
10 11
import eu.dnetlib.utils.MetadataReference;
11 12
import eu.dnetlib.clients.index.utils.ServiceTools;
12 13
import eu.dnetlib.enabling.tools.DnetStreamSupport;
......
118 119
	 * @param dsId            the ds id
119 120
	 * @throws IndexServiceException the index service exception
120 121
	 */
121
	private void deleteByVersion(final IndexCollection indexCollection, final String dsId, final String cqlQuery) throws IndexServiceException {
122
		//final String cqlQuery = IndexFieldUtility.DS_VERSION + " < \"" + IndexDateUtility.getParsedDateField(version) + "\"";
123
		try {
124
			String luceneQuery = translator.getTranslatedQuery(cqlQuery).asLucene();
125
			indexCollection.deleteByQuery(luceneQuery, dsId);
126
		} catch (CQLParseException e) {
127
			throw new IndexServiceException("Cannot parse CQL query into lucene query: " + cqlQuery, e);
128
		} catch (IOException e) {
129
			throw new IndexServiceException("Cannot parse CQL query into lucene query: " + cqlQuery, e);
130
		}
131

  
122
	private void deleteByVersion(final IndexCollection indexCollection, final String dsId, final String version) throws IndexServiceException {
123
		indexCollection.deleteByQuery(String.format("%s:[* TO %s}", IndexFieldUtility.DS_VERSION, version), dsId);
132 124
	}
133 125

  
134 126
	/**

Also available in: Unified diff