diff --git a/6/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java b/6/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java similarity index 91% rename from 6/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java rename to 6/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java index e3e0df0..8e2160b 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java +++ b/6/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.fetcher.ProtoFetcherSingleton; -import com.traveltime.plugin.solr.query.TraveltimeQueryParser; +import com.traveltime.plugin.solr.query.TravelTimeQueryParser; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; @@ -13,7 +13,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeQParserPlugin extends QParserPlugin { +public class TravelTimeQParserPlugin extends QParserPlugin { private String cacheName = RequestCache.NAME; private boolean isFilteringDisabled = false; private String paramPrefix = PARAM_PREFIX; @@ -40,7 +40,7 @@ public void init(NamedList args) { @Override public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { - return new TraveltimeQueryParser( + return new TravelTimeQueryParser( qstr, localParams, params, diff --git a/6/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java b/6/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java index f1d90ce..4e3e459 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java +++ b/6/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java @@ -1,12 +1,12 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; -public class ExactRequestCache extends RequestCache { +public class ExactRequestCache extends RequestCache { private final Object[] lock = new Object[0]; @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/6/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java b/6/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java index 1b845c7..7aaebfd 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java +++ b/6/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java @@ -1,11 +1,11 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import org.apache.solr.search.CacheRegenerator; import java.util.Map; -public class FuzzyRequestCache extends RequestCache { +public class FuzzyRequestCache extends RequestCache { private final Object[] lock = new Object[0]; private Map args; @@ -16,8 +16,8 @@ public Object init(Map args, Object persistence, CacheRegenerator regenerator) { } @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { - key = new TraveltimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { + key = new TravelTimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/6/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java b/6/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java index 99c333f..458cd24 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java +++ b/6/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Set; -//Only for use within TraveltimeDelegatingCollector if no cache is set up +//Only for use within TravelTimeDelegatingCollector if no cache is set up public class UnprotectedTimes extends TravelTimes { private final Object2IntOpenHashMap coordsToTimes = new Object2IntOpenHashMap<>(); diff --git a/6/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java b/6/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java index 56d6457..ffff6e7 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java +++ b/6/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java @@ -1,6 +1,6 @@ package com.traveltime.plugin.solr.fetcher; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import com.traveltime.plugin.solr.util.Util; import com.traveltime.sdk.TravelTimeSDK; import com.traveltime.sdk.auth.TravelTimeCredentials; @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; -public class ProtoFetcher implements Fetcher { +public class ProtoFetcher implements Fetcher { private final TravelTimeSDK api; private final Logger log = LoggerFactory.getLogger(ProtoFetcher.class); @@ -50,7 +50,7 @@ public ProtoFetcher(URI uri, String id, String key) { } @Override - public List getTimes(TraveltimeQueryParameters params, ArrayList destinations) { + public List getTimes(TravelTimeQueryParameters params, ArrayList destinations) { val fastProto = TimeFilterFastProtoRequest .builder() .oneToMany( diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java similarity index 97% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java index 79391e2..baec285 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -public class TraveltimeDelegatingCollector extends DelegatingCollector { +public class TravelTimeDelegatingCollector extends DelegatingCollector { private final LeafReaderContext[] contexts; private final int[] contextBaseStart; private final int[] contextBaseEnd; @@ -43,7 +43,7 @@ public class TraveltimeDelegatingCollector extends D private SortedNumericDocValues coords; - public TraveltimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { + public TravelTimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; this.contextBaseStart = new int[segments]; diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java similarity index 82% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java index 366b830..c1c1e72 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java @@ -15,7 +15,7 @@ import java.util.function.Function; @Data -public class TraveltimeQueryParameters implements QueryParams { +public class TravelTimeQueryParameters implements QueryParams { private final String field; private final Coordinates origin; private final int limit; @@ -44,33 +44,33 @@ private static T findByNameOrError(String what, String name, Function 0"); } - return new TraveltimeQueryParameters(field, origin, limit, mode, country); + return new TravelTimeQueryParameters(field, origin, limit, mode, country); } @Override diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java similarity index 72% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java index 6688d13..697e39b 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java @@ -7,15 +7,15 @@ import org.apache.solr.search.QParser; import org.apache.solr.search.SyntaxError; -public class TraveltimeQueryParser extends QParser { +public class TravelTimeQueryParser extends QParser { private static final String WEIGHT = "weight"; - private final Fetcher fetcher; + private final Fetcher fetcher; private final String cacheName; private final boolean isFilteringDisabled; private final String paramPrefix; - public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { + public TravelTimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { super(qstr, localParams, params, req); this.fetcher = fetcher; this.cacheName = cacheName; @@ -24,7 +24,7 @@ public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -35,11 +35,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } - val params = TraveltimeQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + val params = TravelTimeQueryParameters.parse(req.getSchema(), paramSource); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java similarity index 98% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java index b69a11b..23876fa 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java @@ -41,7 +41,7 @@ @AllArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeSearchQuery extends ExtendedQueryBase implements PostFilter { +public class TravelTimeSearchQuery extends ExtendedQueryBase implements PostFilter { private final Params params; private final float weight; private final Fetcher fetcher; @@ -50,7 +50,7 @@ public class TraveltimeSearchQuery extends ExtendedQ @Override public String toString(String field) { - return String.format("TraveltimeSearchQuery(params = %s)", params); + return String.format("TravelTimeSearchQuery(params = %s)", params); } @Override @@ -59,7 +59,7 @@ public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) { RequestCache cache = (RequestCache) searcher.getCache(cacheName); int maxDoc = searcher.maxDoc(); int leafCount = searcher.getTopReaderContext().leaves().size(); - return new TraveltimeDelegatingCollector<>( + return new TravelTimeDelegatingCollector<>( maxDoc, leafCount, params, diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java similarity index 95% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java index 92f91f9..db04397 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java @@ -17,7 +17,7 @@ @RequiredArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeValueSource extends ValueSource { +public class TravelTimeValueSource extends ValueSource { private final Params params; @EqualsAndHashCode.Exclude private final TravelTimes cache; diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java similarity index 82% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java rename to 6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java index 66307da..1d83cad 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java @@ -12,7 +12,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeValueSourceParser extends ValueSourceParser { +public class TravelTimeValueSourceParser extends ValueSourceParser { private String cacheName = RequestCache.NAME; private String paramPrefix = PARAM_PREFIX; @@ -30,7 +30,7 @@ public void init(NamedList args) { @Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { SolrQueryRequest req = fp.getReq(); - RequestCache cache = (RequestCache) req.getSearcher() + RequestCache cache = (RequestCache) req.getSearcher() .getCache(cacheName); if (cache == null) { throw new SolrException( @@ -39,10 +39,10 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { ); } - val queryParameters = TraveltimeQueryParameters.parse( + val queryParameters = TravelTimeQueryParameters.parse( req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); + return new TravelTimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); } } diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java b/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java index e279361..ad85f64 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.fetcher.Fetcher; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeSearchQuery; +import com.traveltime.plugin.solr.query.TravelTimeSearchQuery; import lombok.val; import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; @@ -26,7 +26,7 @@ public TimeFilterQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -37,11 +37,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } val params = TimeFilterQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java b/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java index 40e04ad..76f11b3 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java +++ b/6/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeValueSource; +import com.traveltime.plugin.solr.query.TravelTimeValueSource; import org.apache.lucene.queries.function.ValueSource; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.NamedList; @@ -44,6 +44,6 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); + return new TravelTimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); } } diff --git a/6/src/test/resources/run-tests.sh b/6/src/test/resources/run-tests.sh index d7d4c61..481f1c7 100644 --- a/6/src/test/resources/run-tests.sh +++ b/6/src/test/resources/run-tests.sh @@ -12,18 +12,18 @@ docker exec $IMAGE_NAME bash -c 'sleep 5; solr create_core -c london' docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-field": {"name":"coords", "type":"location", "stored":true}}' http://localhost:8983/solr/london/schema docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_fuzzy", "class": "com.traveltime.plugin.solr.cache.FuzzyRequestCache", "secondary_size": "150000"}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_exact", "class": "com.traveltime.plugin.solr.cache.ExactRequestCache"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME post -c london part0.json diff --git a/7/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java b/7/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java similarity index 91% rename from 7/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java rename to 7/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java index e3e0df0..8e2160b 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java +++ b/7/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.fetcher.ProtoFetcherSingleton; -import com.traveltime.plugin.solr.query.TraveltimeQueryParser; +import com.traveltime.plugin.solr.query.TravelTimeQueryParser; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; @@ -13,7 +13,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeQParserPlugin extends QParserPlugin { +public class TravelTimeQParserPlugin extends QParserPlugin { private String cacheName = RequestCache.NAME; private boolean isFilteringDisabled = false; private String paramPrefix = PARAM_PREFIX; @@ -40,7 +40,7 @@ public void init(NamedList args) { @Override public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { - return new TraveltimeQueryParser( + return new TravelTimeQueryParser( qstr, localParams, params, diff --git a/7/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java b/7/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java index f1d90ce..4e3e459 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java +++ b/7/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java @@ -1,12 +1,12 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; -public class ExactRequestCache extends RequestCache { +public class ExactRequestCache extends RequestCache { private final Object[] lock = new Object[0]; @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/7/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java b/7/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java index 1b845c7..7aaebfd 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java +++ b/7/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java @@ -1,11 +1,11 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import org.apache.solr.search.CacheRegenerator; import java.util.Map; -public class FuzzyRequestCache extends RequestCache { +public class FuzzyRequestCache extends RequestCache { private final Object[] lock = new Object[0]; private Map args; @@ -16,8 +16,8 @@ public Object init(Map args, Object persistence, CacheRegenerator regenerator) { } @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { - key = new TraveltimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { + key = new TravelTimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/7/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java b/7/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java index 99c333f..458cd24 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java +++ b/7/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Set; -//Only for use within TraveltimeDelegatingCollector if no cache is set up +//Only for use within TravelTimeDelegatingCollector if no cache is set up public class UnprotectedTimes extends TravelTimes { private final Object2IntOpenHashMap coordsToTimes = new Object2IntOpenHashMap<>(); diff --git a/7/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java b/7/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java index 56d6457..ffff6e7 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java +++ b/7/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java @@ -1,6 +1,6 @@ package com.traveltime.plugin.solr.fetcher; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import com.traveltime.plugin.solr.util.Util; import com.traveltime.sdk.TravelTimeSDK; import com.traveltime.sdk.auth.TravelTimeCredentials; @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; -public class ProtoFetcher implements Fetcher { +public class ProtoFetcher implements Fetcher { private final TravelTimeSDK api; private final Logger log = LoggerFactory.getLogger(ProtoFetcher.class); @@ -50,7 +50,7 @@ public ProtoFetcher(URI uri, String id, String key) { } @Override - public List getTimes(TraveltimeQueryParameters params, ArrayList destinations) { + public List getTimes(TravelTimeQueryParameters params, ArrayList destinations) { val fastProto = TimeFilterFastProtoRequest .builder() .oneToMany( diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java similarity index 97% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java index 9654baf..d6961a2 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -public class TraveltimeDelegatingCollector extends DelegatingCollector { +public class TravelTimeDelegatingCollector extends DelegatingCollector { private final LeafReaderContext[] contexts; private final int[] contextBaseStart; private final int[] contextBaseEnd; @@ -43,7 +43,7 @@ public class TraveltimeDelegatingCollector extends D private SortedNumericDocValues coords; - public TraveltimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { + public TravelTimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; this.contextBaseStart = new int[segments]; diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java similarity index 82% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java index 366b830..c1c1e72 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java @@ -15,7 +15,7 @@ import java.util.function.Function; @Data -public class TraveltimeQueryParameters implements QueryParams { +public class TravelTimeQueryParameters implements QueryParams { private final String field; private final Coordinates origin; private final int limit; @@ -44,33 +44,33 @@ private static T findByNameOrError(String what, String name, Function 0"); } - return new TraveltimeQueryParameters(field, origin, limit, mode, country); + return new TravelTimeQueryParameters(field, origin, limit, mode, country); } @Override diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java similarity index 72% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java index 6688d13..697e39b 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java @@ -7,15 +7,15 @@ import org.apache.solr.search.QParser; import org.apache.solr.search.SyntaxError; -public class TraveltimeQueryParser extends QParser { +public class TravelTimeQueryParser extends QParser { private static final String WEIGHT = "weight"; - private final Fetcher fetcher; + private final Fetcher fetcher; private final String cacheName; private final boolean isFilteringDisabled; private final String paramPrefix; - public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { + public TravelTimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { super(qstr, localParams, params, req); this.fetcher = fetcher; this.cacheName = cacheName; @@ -24,7 +24,7 @@ public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -35,11 +35,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } - val params = TraveltimeQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + val params = TravelTimeQueryParameters.parse(req.getSchema(), paramSource); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java similarity index 98% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java index 5e73a5f..f1b85f9 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java @@ -40,7 +40,7 @@ @AllArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeSearchQuery extends ExtendedQueryBase implements PostFilter { +public class TravelTimeSearchQuery extends ExtendedQueryBase implements PostFilter { private final Params params; private final float weight; private final Fetcher fetcher; @@ -49,7 +49,7 @@ public class TraveltimeSearchQuery extends ExtendedQ @Override public String toString(String field) { - return String.format("TraveltimeSearchQuery(params = %s)", params); + return String.format("TravelTimeSearchQuery(params = %s)", params); } @Override @@ -58,7 +58,7 @@ public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) { RequestCache cache = (RequestCache) searcher.getCache(cacheName); int maxDoc = searcher.maxDoc(); int leafCount = searcher.getTopReaderContext().leaves().size(); - return new TraveltimeDelegatingCollector<>( + return new TravelTimeDelegatingCollector<>( maxDoc, leafCount, params, diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java similarity index 95% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java index 4ac4cd6..23c40a3 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java @@ -18,7 +18,7 @@ @RequiredArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeValueSource extends ValueSource { +public class TravelTimeValueSource extends ValueSource { private final Params params; @EqualsAndHashCode.Exclude private final TravelTimes cache; diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java similarity index 82% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java rename to 7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java index 66307da..1d83cad 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java @@ -12,7 +12,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeValueSourceParser extends ValueSourceParser { +public class TravelTimeValueSourceParser extends ValueSourceParser { private String cacheName = RequestCache.NAME; private String paramPrefix = PARAM_PREFIX; @@ -30,7 +30,7 @@ public void init(NamedList args) { @Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { SolrQueryRequest req = fp.getReq(); - RequestCache cache = (RequestCache) req.getSearcher() + RequestCache cache = (RequestCache) req.getSearcher() .getCache(cacheName); if (cache == null) { throw new SolrException( @@ -39,10 +39,10 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { ); } - val queryParameters = TraveltimeQueryParameters.parse( + val queryParameters = TravelTimeQueryParameters.parse( req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); + return new TravelTimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); } } diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java b/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java index e279361..ad85f64 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.fetcher.Fetcher; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeSearchQuery; +import com.traveltime.plugin.solr.query.TravelTimeSearchQuery; import lombok.val; import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; @@ -26,7 +26,7 @@ public TimeFilterQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -37,11 +37,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } val params = TimeFilterQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java b/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java index 40e04ad..76f11b3 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java +++ b/7/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeValueSource; +import com.traveltime.plugin.solr.query.TravelTimeValueSource; import org.apache.lucene.queries.function.ValueSource; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.NamedList; @@ -44,6 +44,6 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); + return new TravelTimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); } } diff --git a/7/src/test/resources/run-tests.sh b/7/src/test/resources/run-tests.sh index 1c47ad3..86971d9 100644 --- a/7/src/test/resources/run-tests.sh +++ b/7/src/test/resources/run-tests.sh @@ -12,18 +12,18 @@ docker exec $IMAGE_NAME bash -c 'sleep 5; solr create_core -c london' docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-field": {"name":"coords", "type":"location", "stored":true}}' http://localhost:8983/solr/london/schema docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_fuzzy", "class": "com.traveltime.plugin.solr.cache.FuzzyRequestCache", "secondary_size": "150000"}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_exact", "class": "com.traveltime.plugin.solr.cache.ExactRequestCache"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME post -c london part0.json diff --git a/8/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java b/8/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java similarity index 91% rename from 8/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java rename to 8/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java index e3e0df0..8e2160b 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java +++ b/8/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.fetcher.ProtoFetcherSingleton; -import com.traveltime.plugin.solr.query.TraveltimeQueryParser; +import com.traveltime.plugin.solr.query.TravelTimeQueryParser; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; @@ -13,7 +13,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeQParserPlugin extends QParserPlugin { +public class TravelTimeQParserPlugin extends QParserPlugin { private String cacheName = RequestCache.NAME; private boolean isFilteringDisabled = false; private String paramPrefix = PARAM_PREFIX; @@ -40,7 +40,7 @@ public void init(NamedList args) { @Override public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { - return new TraveltimeQueryParser( + return new TravelTimeQueryParser( qstr, localParams, params, diff --git a/8/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java b/8/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java index f1d90ce..4e3e459 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java +++ b/8/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java @@ -1,12 +1,12 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; -public class ExactRequestCache extends RequestCache { +public class ExactRequestCache extends RequestCache { private final Object[] lock = new Object[0]; @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/8/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java b/8/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java index 1b845c7..7aaebfd 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java +++ b/8/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java @@ -1,11 +1,11 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import org.apache.solr.search.CacheRegenerator; import java.util.Map; -public class FuzzyRequestCache extends RequestCache { +public class FuzzyRequestCache extends RequestCache { private final Object[] lock = new Object[0]; private Map args; @@ -16,8 +16,8 @@ public Object init(Map args, Object persistence, CacheRegenerator regenerator) { } @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { - key = new TraveltimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { + key = new TravelTimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/8/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java b/8/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java index 99c333f..458cd24 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java +++ b/8/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Set; -//Only for use within TraveltimeDelegatingCollector if no cache is set up +//Only for use within TravelTimeDelegatingCollector if no cache is set up public class UnprotectedTimes extends TravelTimes { private final Object2IntOpenHashMap coordsToTimes = new Object2IntOpenHashMap<>(); diff --git a/8/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java b/8/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java index 56d6457..ffff6e7 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java +++ b/8/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java @@ -1,6 +1,6 @@ package com.traveltime.plugin.solr.fetcher; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import com.traveltime.plugin.solr.util.Util; import com.traveltime.sdk.TravelTimeSDK; import com.traveltime.sdk.auth.TravelTimeCredentials; @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; -public class ProtoFetcher implements Fetcher { +public class ProtoFetcher implements Fetcher { private final TravelTimeSDK api; private final Logger log = LoggerFactory.getLogger(ProtoFetcher.class); @@ -50,7 +50,7 @@ public ProtoFetcher(URI uri, String id, String key) { } @Override - public List getTimes(TraveltimeQueryParameters params, ArrayList destinations) { + public List getTimes(TravelTimeQueryParameters params, ArrayList destinations) { val fastProto = TimeFilterFastProtoRequest .builder() .oneToMany( diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java similarity index 97% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java index 4d41a34..854ace7 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -public class TraveltimeDelegatingCollector extends DelegatingCollector { +public class TravelTimeDelegatingCollector extends DelegatingCollector { private final LeafReaderContext[] contexts; private final int[] contextBaseStart; private final int[] contextBaseEnd; @@ -43,7 +43,7 @@ public class TraveltimeDelegatingCollector extends D private SortedNumericDocValues coords; - public TraveltimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { + public TravelTimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; this.contextBaseStart = new int[segments]; diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java similarity index 82% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java index 366b830..c1c1e72 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java @@ -15,7 +15,7 @@ import java.util.function.Function; @Data -public class TraveltimeQueryParameters implements QueryParams { +public class TravelTimeQueryParameters implements QueryParams { private final String field; private final Coordinates origin; private final int limit; @@ -44,33 +44,33 @@ private static T findByNameOrError(String what, String name, Function 0"); } - return new TraveltimeQueryParameters(field, origin, limit, mode, country); + return new TravelTimeQueryParameters(field, origin, limit, mode, country); } @Override diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java similarity index 72% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java index 6688d13..697e39b 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java @@ -7,15 +7,15 @@ import org.apache.solr.search.QParser; import org.apache.solr.search.SyntaxError; -public class TraveltimeQueryParser extends QParser { +public class TravelTimeQueryParser extends QParser { private static final String WEIGHT = "weight"; - private final Fetcher fetcher; + private final Fetcher fetcher; private final String cacheName; private final boolean isFilteringDisabled; private final String paramPrefix; - public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { + public TravelTimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { super(qstr, localParams, params, req); this.fetcher = fetcher; this.cacheName = cacheName; @@ -24,7 +24,7 @@ public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -35,11 +35,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } - val params = TraveltimeQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + val params = TravelTimeQueryParameters.parse(req.getSchema(), paramSource); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java similarity index 98% rename from 8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java index e42dff8..42f7011 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java @@ -40,7 +40,7 @@ @AllArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeSearchQuery extends ExtendedQueryBase implements PostFilter { +public class TravelTimeSearchQuery extends ExtendedQueryBase implements PostFilter { private final Params params; private final float weight; private final Fetcher fetcher; @@ -49,7 +49,7 @@ public class TraveltimeSearchQuery extends ExtendedQ @Override public String toString(String field) { - return String.format("TraveltimeSearchQuery(params = %s)", params); + return String.format("TravelTimeSearchQuery(params = %s)", params); } @Override @@ -58,7 +58,7 @@ public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) { RequestCache cache = (RequestCache) searcher.getCache(cacheName); int maxDoc = searcher.maxDoc(); int leafCount = searcher.getTopReaderContext().leaves().size(); - return new TraveltimeDelegatingCollector<>( + return new TravelTimeDelegatingCollector<>( maxDoc, leafCount, params, diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java similarity index 95% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java index 4ac4cd6..23c40a3 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java @@ -18,7 +18,7 @@ @RequiredArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeValueSource extends ValueSource { +public class TravelTimeValueSource extends ValueSource { private final Params params; @EqualsAndHashCode.Exclude private final TravelTimes cache; diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java similarity index 82% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java rename to 8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java index 66307da..1d83cad 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java @@ -12,7 +12,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeValueSourceParser extends ValueSourceParser { +public class TravelTimeValueSourceParser extends ValueSourceParser { private String cacheName = RequestCache.NAME; private String paramPrefix = PARAM_PREFIX; @@ -30,7 +30,7 @@ public void init(NamedList args) { @Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { SolrQueryRequest req = fp.getReq(); - RequestCache cache = (RequestCache) req.getSearcher() + RequestCache cache = (RequestCache) req.getSearcher() .getCache(cacheName); if (cache == null) { throw new SolrException( @@ -39,10 +39,10 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { ); } - val queryParameters = TraveltimeQueryParameters.parse( + val queryParameters = TravelTimeQueryParameters.parse( req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); + return new TravelTimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); } } diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java b/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java index e279361..ad85f64 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.fetcher.Fetcher; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeSearchQuery; +import com.traveltime.plugin.solr.query.TravelTimeSearchQuery; import lombok.val; import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; @@ -26,7 +26,7 @@ public TimeFilterQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -37,11 +37,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } val params = TimeFilterQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java b/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java index 40e04ad..76f11b3 100755 --- a/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java +++ b/8/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeValueSource; +import com.traveltime.plugin.solr.query.TravelTimeValueSource; import org.apache.lucene.queries.function.ValueSource; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.NamedList; @@ -44,6 +44,6 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); + return new TravelTimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); } } diff --git a/8/src/test/resources/run-tests.sh b/8/src/test/resources/run-tests.sh index 1c47ad3..86971d9 100644 --- a/8/src/test/resources/run-tests.sh +++ b/8/src/test/resources/run-tests.sh @@ -12,18 +12,18 @@ docker exec $IMAGE_NAME bash -c 'sleep 5; solr create_core -c london' docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-field": {"name":"coords", "type":"location", "stored":true}}' http://localhost:8983/solr/london/schema docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_fuzzy", "class": "com.traveltime.plugin.solr.cache.FuzzyRequestCache", "secondary_size": "150000"}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_exact", "class": "com.traveltime.plugin.solr.cache.ExactRequestCache"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME post -c london part0.json diff --git a/9/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java b/9/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java similarity index 91% rename from 9/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java rename to 9/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java index e3e0df0..8e2160b 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/TraveltimeQParserPlugin.java +++ b/9/src/main/java/com/traveltime/plugin/solr/TravelTimeQParserPlugin.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.fetcher.ProtoFetcherSingleton; -import com.traveltime.plugin.solr.query.TraveltimeQueryParser; +import com.traveltime.plugin.solr.query.TravelTimeQueryParser; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; @@ -13,7 +13,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeQParserPlugin extends QParserPlugin { +public class TravelTimeQParserPlugin extends QParserPlugin { private String cacheName = RequestCache.NAME; private boolean isFilteringDisabled = false; private String paramPrefix = PARAM_PREFIX; @@ -40,7 +40,7 @@ public void init(NamedList args) { @Override public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { - return new TraveltimeQueryParser( + return new TravelTimeQueryParser( qstr, localParams, params, diff --git a/9/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java b/9/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java index f1d90ce..4e3e459 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java +++ b/9/src/main/java/com/traveltime/plugin/solr/cache/ExactRequestCache.java @@ -1,12 +1,12 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; -public class ExactRequestCache extends RequestCache { +public class ExactRequestCache extends RequestCache { private final Object[] lock = new Object[0]; @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/9/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java b/9/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java index aa9ea2b..6be899d 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java +++ b/9/src/main/java/com/traveltime/plugin/solr/cache/FuzzyRequestCache.java @@ -1,11 +1,11 @@ package com.traveltime.plugin.solr.cache; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import org.apache.solr.search.CacheRegenerator; import java.util.Map; -public class FuzzyRequestCache extends RequestCache { +public class FuzzyRequestCache extends RequestCache { private final Object[] lock = new Object[0]; private Map args; @@ -16,8 +16,8 @@ public Object init(Map args, Object persistence, CacheRegenerato } @Override - public TravelTimes getOrFresh(TraveltimeQueryParameters key) { - key = new TraveltimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); + public TravelTimes getOrFresh(TravelTimeQueryParameters key) { + key = new TravelTimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null); TravelTimes result = get(key); if (result == null) { synchronized (lock) { diff --git a/9/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java b/9/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java index 99c333f..458cd24 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java +++ b/9/src/main/java/com/traveltime/plugin/solr/cache/UnprotectedTimes.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Set; -//Only for use within TraveltimeDelegatingCollector if no cache is set up +//Only for use within TravelTimeDelegatingCollector if no cache is set up public class UnprotectedTimes extends TravelTimes { private final Object2IntOpenHashMap coordsToTimes = new Object2IntOpenHashMap<>(); diff --git a/9/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java b/9/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java index 56d6457..ffff6e7 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java +++ b/9/src/main/java/com/traveltime/plugin/solr/fetcher/ProtoFetcher.java @@ -1,6 +1,6 @@ package com.traveltime.plugin.solr.fetcher; -import com.traveltime.plugin.solr.query.TraveltimeQueryParameters; +import com.traveltime.plugin.solr.query.TravelTimeQueryParameters; import com.traveltime.plugin.solr.util.Util; import com.traveltime.sdk.TravelTimeSDK; import com.traveltime.sdk.auth.TravelTimeCredentials; @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; -public class ProtoFetcher implements Fetcher { +public class ProtoFetcher implements Fetcher { private final TravelTimeSDK api; private final Logger log = LoggerFactory.getLogger(ProtoFetcher.class); @@ -50,7 +50,7 @@ public ProtoFetcher(URI uri, String id, String key) { } @Override - public List getTimes(TraveltimeQueryParameters params, ArrayList destinations) { + public List getTimes(TravelTimeQueryParameters params, ArrayList destinations) { val fastProto = TimeFilterFastProtoRequest .builder() .oneToMany( diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java similarity index 97% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java index 4d41a34..854ace7 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeDelegatingCollector.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeDelegatingCollector.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -public class TraveltimeDelegatingCollector extends DelegatingCollector { +public class TravelTimeDelegatingCollector extends DelegatingCollector { private final LeafReaderContext[] contexts; private final int[] contextBaseStart; private final int[] contextBaseEnd; @@ -43,7 +43,7 @@ public class TraveltimeDelegatingCollector extends D private SortedNumericDocValues coords; - public TraveltimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { + public TravelTimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher fetcher, RequestCache cache, boolean isFilteringDisabled) { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; this.contextBaseStart = new int[segments]; diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java similarity index 82% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java index 16d3592..844f77b 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParameters.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParameters.java @@ -15,7 +15,7 @@ import java.util.function.Function; @Data -public class TraveltimeQueryParameters implements QueryParams { +public class TravelTimeQueryParameters implements QueryParams { private final String field; private final Coordinates origin; private final int limit; @@ -44,33 +44,33 @@ private static T findByNameOrError(String what, String name, Function 0"); } - return new TraveltimeQueryParameters(field, origin, limit, mode, country); + return new TravelTimeQueryParameters(field, origin, limit, mode, country); } @Override diff --git a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java similarity index 72% rename from 6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java index 6688d13..697e39b 100755 --- a/6/src/main/java/com/traveltime/plugin/solr/query/TraveltimeQueryParser.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeQueryParser.java @@ -7,15 +7,15 @@ import org.apache.solr.search.QParser; import org.apache.solr.search.SyntaxError; -public class TraveltimeQueryParser extends QParser { +public class TravelTimeQueryParser extends QParser { private static final String WEIGHT = "weight"; - private final Fetcher fetcher; + private final Fetcher fetcher; private final String cacheName; private final boolean isFilteringDisabled; private final String paramPrefix; - public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { + public TravelTimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) { super(qstr, localParams, params, req); this.fetcher = fetcher; this.cacheName = cacheName; @@ -24,7 +24,7 @@ public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -35,11 +35,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } - val params = TraveltimeQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + val params = TravelTimeQueryParameters.parse(req.getSchema(), paramSource); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java similarity index 98% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java index 5a43d00..2f2402a 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeSearchQuery.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeSearchQuery.java @@ -39,7 +39,7 @@ @AllArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeSearchQuery extends ExtendedQueryBase implements PostFilter { +public class TravelTimeSearchQuery extends ExtendedQueryBase implements PostFilter { private final Params params; private final float weight; private final Fetcher fetcher; @@ -48,7 +48,7 @@ public class TraveltimeSearchQuery extends ExtendedQ @Override public String toString(String field) { - return String.format("TraveltimeSearchQuery(params = %s)", params); + return String.format("TravelTimeSearchQuery(params = %s)", params); } @Override @@ -62,7 +62,7 @@ public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) { RequestCache cache = (RequestCache) searcher.getCache(cacheName); int maxDoc = searcher.maxDoc(); int leafCount = searcher.getTopReaderContext().leaves().size(); - return new TraveltimeDelegatingCollector<>( + return new TravelTimeDelegatingCollector<>( maxDoc, leafCount, params, diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java similarity index 95% rename from 9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java index 4ac4cd6..23c40a3 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSource.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSource.java @@ -18,7 +18,7 @@ @RequiredArgsConstructor @EqualsAndHashCode(callSuper = false) -public class TraveltimeValueSource extends ValueSource { +public class TravelTimeValueSource extends ValueSource { private final Params params; @EqualsAndHashCode.Exclude private final TravelTimes cache; diff --git a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java similarity index 82% rename from 7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java rename to 9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java index 66307da..1d83cad 100755 --- a/7/src/main/java/com/traveltime/plugin/solr/query/TraveltimeValueSourceParser.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/TravelTimeValueSourceParser.java @@ -12,7 +12,7 @@ import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX; -public class TraveltimeValueSourceParser extends ValueSourceParser { +public class TravelTimeValueSourceParser extends ValueSourceParser { private String cacheName = RequestCache.NAME; private String paramPrefix = PARAM_PREFIX; @@ -30,7 +30,7 @@ public void init(NamedList args) { @Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { SolrQueryRequest req = fp.getReq(); - RequestCache cache = (RequestCache) req.getSearcher() + RequestCache cache = (RequestCache) req.getSearcher() .getCache(cacheName); if (cache == null) { throw new SolrException( @@ -39,10 +39,10 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { ); } - val queryParameters = TraveltimeQueryParameters.parse( + val queryParameters = TravelTimeQueryParameters.parse( req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); + return new TravelTimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters)); } } diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java b/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java index e279361..ad85f64 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterQueryParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.fetcher.Fetcher; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeSearchQuery; +import com.traveltime.plugin.solr.query.TravelTimeSearchQuery; import lombok.val; import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; @@ -26,7 +26,7 @@ public TimeFilterQueryParser(String qstr, SolrParams localParams, SolrParams par } @Override - public TraveltimeSearchQuery parse() throws SyntaxError { + public TravelTimeSearchQuery parse() throws SyntaxError { ParamSource paramSource = new ParamSource(paramPrefix, localParams, params); float weight; try { @@ -37,11 +37,11 @@ public TraveltimeSearchQuery parse() throws SyntaxErr throw new SyntaxError("Couldn't parse traveltime weight as a float"); } if (weight < 0 || weight > 1) { - throw new SyntaxError("Traveltime weight must be between 0 and 1"); + throw new SyntaxError("TravelTime weight must be between 0 and 1"); } val params = TimeFilterQueryParameters.parse(req.getSchema(), paramSource); - return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); + return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled); } } diff --git a/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java b/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java index 40e04ad..76f11b3 100755 --- a/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java +++ b/9/src/main/java/com/traveltime/plugin/solr/query/timefilter/TimeFilterValueSourceParser.java @@ -2,7 +2,7 @@ import com.traveltime.plugin.solr.cache.RequestCache; import com.traveltime.plugin.solr.query.ParamSource; -import com.traveltime.plugin.solr.query.TraveltimeValueSource; +import com.traveltime.plugin.solr.query.TravelTimeValueSource; import org.apache.lucene.queries.function.ValueSource; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.NamedList; @@ -44,6 +44,6 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError { req.getSchema(), new ParamSource(paramPrefix, fp.getParams()) ); - return new TraveltimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); + return new TravelTimeValueSource<>(queryParams, cache.getOrFresh(queryParams)); } } diff --git a/9/src/test/resources/run-tests.sh b/9/src/test/resources/run-tests.sh index 291d8ca..17e5361 100644 --- a/9/src/test/resources/run-tests.sh +++ b/9/src/test/resources/run-tests.sh @@ -12,18 +12,18 @@ docker exec $IMAGE_NAME bash -c 'sleep 5; solr create_core -c london' docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-field": {"name":"coords", "type":"location", "stored":true}}' http://localhost:8983/solr/london/schema docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_fuzzy", "class": "com.traveltime.plugin.solr.cache.FuzzyRequestCache", "secondary_size": "150000"}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-cache": {"name": "traveltime_exact", "class": "com.traveltime.plugin.solr.cache.ExactRequestCache"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TraveltimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config - -docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TraveltimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_e", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_f", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_fuzzy"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_walking", "prefix": "walking_", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_driving", "prefix": "driving_", "class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-valuesourceparser": {"name": "traveltime_walking", "prefix": "walking_","class": "com.traveltime.plugin.solr.query.TravelTimeValueSourceParser", "cache": "traveltime_exact"}}' http://localhost:8983/solr/london/config + +docker exec $IMAGE_NAME curl -s -o /dev/null -X POST -H 'Content-type:application/json' -d '{"add-queryparser": {"name": "traveltime_nofilter", "class": "com.traveltime.plugin.solr.TravelTimeQParserPlugin", "api_uri": "http://localhost/", "app_id": "id", "api_key": "key", "filtering_disabled": true}}' http://localhost:8983/solr/london/config docker exec $IMAGE_NAME post -c london part0.json diff --git a/README.md b/README.md index d873986..42a528e 100755 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # traveltime-solr-plugin -Plugin for Solr that allows users to filter locations using the Traveltime API. +Plugin for Solr that allows users to filter locations using the TravelTime API. ## Installation & configuration This is a standard Solr plugin. The plugin jar must be copied into the [solr lib directory](https://solr.apache.org/guide/8_4/libs.html#lib-directories) -To use the plugin you **must** add a `queryParser` with the class `com.traveltime.plugin.solr.TraveltimeQParserPlugin` or +To use the plugin you **must** add a `queryParser` with the class `com.traveltime.plugin.solr.TravelTimeQParserPlugin` or `com.traveltime.plugin.solr.TimeFilterQParserPlugin` (currently only available for solar version 8). This query parser has two mandatory string configuration options: - `app_id`: this is you API app id. @@ -14,7 +14,7 @@ This query parser has two mandatory string configuration options: The `TimeFilterQParserPlugin` has an optional integer field `location_limit` which represents the maximum amount of locations that can be sent in a single request. Defaults to 2000, only increase this parameter if you API plan supports larger requests. ```xml - + your_app_id_here your_api_key_here @@ -47,7 +47,7 @@ The query accepts the following (mandatory) configuration options: - `origin`: the point from which travel time will be measured. The accepted formats are: - `"lat,lon"` string - geohash -- `field`: the document field that will be used as the destination in the Traveltime query. +- `field`: the document field that will be used as the destination in the TravelTime query. - `limit`: the travel time limit in seconds. Must be non-negative. - `mode`: Transportation mode used in the search. One of: `pt`, `walking+ferry`, `cycling+ferry`, `driving+ferry`. - `country`: Country that the `origin` is in. Currently may only be one of: `uk`, `nl`, `at`, `be`, `de`, `fr`, `ie`, `lt`. @@ -57,7 +57,7 @@ If a parameter is specified in both ways, the local parameter takes precedence. ## Querying data using json time-filter requests The query accepts the following configuration options: -- `field`: the document field that will be used as the destination in the Traveltime query. +- `field`: the document field that will be used as the destination in the TravelTime query. - `travel_time`: the travel time limit in seconds. Must be non-negative. - For arrival searches: - `arrival_time`: arrival time in ISO8601 @@ -67,9 +67,9 @@ The query accepts the following configuration options: - `departure_time`: departure time in ISO8601 - `departure_location`: string containing a JSON object with `lat` and `lng` keys describing the coordinates of the departure location -- `transportation`: a string containing a JSON object describing the transportation mode as defined by the Traveltime API: +- `transportation`: a string containing a JSON object describing the transportation mode as defined by the TravelTime API: https://docs.traveltime.com/api/reference/travel-time-distance-matrix#departure_searches-transportation -- (optional) `range`: : a string containing a JSON object describing the range search as defined by the Traveltime API: +- (optional) `range`: : a string containing a JSON object describing the range search as defined by the TravelTime API: https://docs.traveltime.com/api/reference/travel-time-distance-matrix#departure_searches-range An example query using `curl`: @@ -105,4 +105,4 @@ Therefore, changing any of the parameters will result in a cache miss. This is recommended if the cache is only needed to display the times in search results, or if the query parameters are mostly static. `FuzzyRequestCache` uses only the `origin` and `mode` fields as cache keys. -This cache is useful for workloads where the set of possible `origin` parameters is limited since it will limit the amount of API calls needed to fetch data from Traveltime. The `secondary_size` controls the size of each per-origin traveltime cache. It should be set to at least the number of documents returned by each query. +This cache is useful for workloads where the set of possible `origin` parameters is limited since it will limit the amount of API calls needed to fetch data from TravelTime. The `secondary_size` controls the size of each per-origin traveltime cache. It should be set to at least the number of documents returned by each query.