OK so:

This is solr 5.2.1 (however we had the same problem with 5.1.0, which prompted 
us to upgrade in the first place)
The schema is brand new with 5.1.0.  The daterangefield is defined simply as:


<field name="sku_history.date_range" type="daterange" indexed="true" 
stored="true" />

referring to:

<fieldType name="daterange" class="solr.DateRangeField" />

Through the Solr admin panel, this filter query works:

sku_history.date_range: [2015-05-01T00:00:00Z TO 2015-05-15T00:00:00Z]

Debug output is:

"debug": { "rawquerystring": "*:*", "querystring": "*:*", "parsedquery": 
"MatchAllDocsQuery(*:*)", "parsedquery_toString": "*:*", "explain": { 
"sku_history.982": "\n1.0 = *:*, product of:\n 1.0 = boost\n 1.0 = 
queryNorm\n", "sku_history.4300": "\n1.0 = *:*, product of:\n 1.0 = boost\n 1.0 
= queryNorm\n", "sku_history.12134": "\n1.0 = *:*, product of:\n 1.0 = boost\n 
1.0 = queryNorm\n", "sku_history.15980": "\n1.0 = *:*, product of:\n 1.0 = 
boost\n 1.0 = queryNorm\n", "sku_history.20176": "\n1.0 = *:*, product of:\n 
1.0 = boost\n 1.0 = queryNorm\n", "sku_history.21937": "\n1.0 = *:*, product 
of:\n 1.0 = boost\n 1.0 = queryNorm\n", "sku_history.21938": "\n1.0 = *:*, 
product of:\n 1.0 = boost\n 1.0 = queryNorm\n", "sku_history.21940": "\n1.0 = 
*:*, product of:\n 1.0 = boost\n 1.0 = queryNorm\n", "sku_history.26160": 
"\n1.0 = *:*, product of:\n 1.0 = boost\n 1.0 = queryNorm\n", 
"sku_history.26161": "\n1.0 = *:*, product of:\n 1.0 = boost\n 1.0 = 
queryNorm\n" }, "QParser": "LuceneQParser", "filter_queries": [ 
"sku_history.date_range: [2015-05-01T00:00:00Z TO 2015-05-15T00:00:00Z]" ], 
"parsed_filter_queries": [ 
"ConstantScore(IntersectsPrefixTreeFilter(fieldName=sku_history.date_range,queryShape=[2015-05
 TO 2015-05-15T00:00:00.000],detailLevel=9,prefixGridScanLevel=7))" ], 
"timing": {snipped}

}

"dateRangeField" is instantiated as:

 private static final DateRangeField dateRangeField = new DateRangeField();

The first use of the field in the code after that is the line I already sent:

dateRangeQuery = dateRangeField.getRangeQuery(null, 
SidxS.getSchema().getField("sku_history.date_range"), start_date_str, 
end_date_str, true, true);

The field name appears to be correct.

I've attached a screenshot from the schema browser:


[Inline image 1]


Now that mention debugQuery - I see that the actual filter the standard query 
parser is using is constructed with IntersectsPrefixTreeFilter.    I'm going to 
try just modeling my filter based on the template laid out there and see if 
that works as a workaround.


--

Steve

On Tue, Aug 4, 2015 at 7:01 AM, Mikhail Khludnev 
<mkhlud...@griddynamics.com<mailto:mkhlud...@griddynamics.com>> wrote:
Hm... This puzzle is more difficult, I need more clues.
What's the version of Solr? Can't it happen you inherited schema.xml from the 
older version of Solr?
Which "Web-based queries work fine," you run exactly and what's the output with 
debugQuery=true?
How exactly do you obtain dateRangeField? are you sure that 
"sku_history.date_range" is correct name, and matches to daterange field in 
schema.xml?
What's the field&type definition for dateRangeField "sku_history.date_range" in 
 schema.xml? and what\s excatly you see in SolrAdmin/SchemaBrowser for them?

Sorry for such long list, but remote custom code troubleshooting never be easy.


On Tue, Aug 4, 2015 at 2:30 AM, Stephen Weiss 
<steve.we...@wgsn.com<mailto:steve.we...@wgsn.com>> wrote:
Thanks again.  Any chance you have a thought on this one?  :-)

---------- Forwarded message ----------
From: Stephen Weiss <steve.we...@wgsn.com<mailto:steve.we...@wgsn.com>>
Date: Mon, Aug 3, 2015 at 7:28 PM
Subject: DateRangeField Query throws NPE
To: solr-user@lucene.apache.org<mailto:solr-user@lucene.apache.org>


Hi everyone,

I'm running into a trouble building a query with DateRangeField.  Web-based 
queries work fine, but this code throws an NPE:


dateRangeQuery = dateRangeField.getRangeQuery(null, 
SidxS.getSchema().getField("sku_history.date_range"), start_date_str, 
end_date_str, true, true);

ERROR - 2015-08-03 23:07:10.122; [   instock_dev] 
org.apache.solr.common.SolrException; 
null:com.google.common.util.concurrent.UncheckedExecutionException: 
java.lang.NullPointerException
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2263)
at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4789)
at 
org.apache.solr.schema.AbstractSpatialFieldType.getStrategy(AbstractSpatialFieldType.java:403)
at 
org.apache.solr.schema.AbstractSpatialFieldType.getQueryFromSpatialArgs(AbstractSpatialFieldType.java:331)
at org.apache.solr.schema.DateRangeField.getRangeQuery(DateRangeField.java:184)
at 
com.wgsn.ginger.stockStatusQuery.getFilterCollector(stockStatusQuery.java:128)
at 
org.apache.solr.search.SolrIndexSearcher.getProcessedFilter(SolrIndexSearcher.java:1148)
at 
org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1609)
at 
org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1485)
at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:561)
at 
org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:518)
at 
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:255)
at 
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2064)
...
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at 
org.apache.solr.schema.AbstractSpatialPrefixTreeFieldType.newSpatialStrategy(AbstractSpatialPrefixTreeFieldType.java:117)
at 
org.apache.solr.schema.AbstractSpatialPrefixTreeFieldType.newSpatialStrategy(AbstractSpatialPrefixTreeFieldType.java:40)
at 
org.apache.solr.schema.AbstractSpatialFieldType$2.call(AbstractSpatialFieldType.java:406)
at 
org.apache.solr.schema.AbstractSpatialFieldType$2.call(AbstractSpatialFieldType.java:403)
at 
com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4792)
at 
com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3599)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2379)
at 
com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2342)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2257)
... 38 more


That line 117 seems to be some logging happening in that class, which is 
probably unnecessary to begin with:

log<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.solr/solr-core/5.1.0/org/apache/solr/schema/AbstractSpatialFieldType.java#AbstractSpatialFieldType.0log>.info<http://grepcode.com/file/repo1.maven.org/maven2/org.slf4j/slf4j-api/1.7.7/org/slf4j/Logger.java#Logger.info%28java.lang.String%29>(this.toString<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.solr/solr-core/5.1.0/org/apache/solr/schema/FieldType.java#FieldType.toString%28%29>()+"
 strat: "+strat+" maxLevels: "+ 
grid<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.solr/solr-core/5.1.0/org/apache/solr/schema/AbstractSpatialPrefixTreeFieldType.java#AbstractSpatialPrefixTreeFieldType.0grid>.getMaxLevels<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-spatial/5.1.0/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTree.java#SpatialPrefixTree.getMaxLevels%28%29>());//TODO
 output maxDetailKm

No idea which variable is returning null, kinda guessing it's the 
grid.getMaxLevels() since I don't see this being initialized by any prior 
methods in this chain.  Is this just a bug or am I using it wrong?  I'm trying 
to wrap this query together with two other queries but I can't even get the 
Query object back.

--
Steve


________________________________

WGSN is a global foresight business. Our experts provide deep insight and 
analysis of consumer, fashion and design trends. We inspire our clients to plan 
and trade their range with unparalleled confidence and accuracy. Together, we 
Create Tomorrow.

WGSN<http://www.wgsn.com/> is part of WGSN Limited, comprising of 
market-leading products including WGSN.com<http://www.wgsn.com>, WGSN Lifestyle 
& Interiors<http://www.wgsn.com/en/lifestyle-interiors>, WGSN 
INstock<http://www.wgsninstock.com/>, WGSN 
StyleTrial<http://www.wgsn.com/en/styletrial/> and WGSN 
Mindset<http://www.wgsn.com/en/services/consultancy/>, our bespoke consultancy 
services.

The information in or attached to this email is confidential and may be legally 
privileged. If you are not the intended recipient of this message, any use, 
disclosure, copying, distribution or any action taken in reliance on it is 
prohibited and may be unlawful. If you have received this message in error, 
please notify the sender immediately by return email and delete this message 
and any copies from your computer and network. WGSN does not warrant that this 
email and any attachments are free from viruses and accepts no liability for 
any loss resulting from infected email transmissions.

WGSN reserves the right to monitor all email through its networks. Any views 
expressed may be those of the originator and not necessarily of WGSN. WGSN is 
powered by Top Right Group<http://www.topright-group.com>, which transforms 
knowledge businesses to deliver exceptional performance.

Please be advised all phone calls may be recorded for training and quality 
purposes and by accepting and/or making calls from and/or to us you acknowledge 
and agree to calls being recorded.

WGSN Limited, Company number 4858491

registered address:

Top Right Group Limited, The Prow, 1 Wilder Walk, London W1B 5AP

WGSN Inc., tax ID 04-3851246, registered office c/o National Registered Agents, 
Inc., 160 Greentree Drive, Suite 101, Dover DE 19904, United States

4C Serviços de Informação Ltda., CNPJ/MF (Taxpayer's Register): 
15.536.968/0001-04, Address: Avenida Nove de Julho, 5966, Loja, CEP 01406-200, 
Jardim Europa, São Paulo

4C Business Information Consulting (Shanghai) Co., Ltd, 富新商务信息咨询(上海)有限公司, 
registered address Unit 4810/4811, 48/F Tower 1, Grand Gateway, 1 Hong Qiao 
Road, Xuhui District, Shanghai



--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mailto:mkhlud...@griddynamics.com>


________________________________

WGSN is a global foresight business. Our experts provide deep insight and 
analysis of consumer, fashion and design trends. We inspire our clients to plan 
and trade their range with unparalleled confidence and accuracy. Together, we 
Create Tomorrow.

WGSN<http://www.wgsn.com/> is part of WGSN Limited, comprising of 
market-leading products including WGSN.com<http://www.wgsn.com>, WGSN Lifestyle 
& Interiors<http://www.wgsn.com/en/lifestyle-interiors>, WGSN 
INstock<http://www.wgsninstock.com/>, WGSN 
StyleTrial<http://www.wgsn.com/en/styletrial/> and WGSN 
Mindset<http://www.wgsn.com/en/services/consultancy/>, our bespoke consultancy 
services.

The information in or attached to this email is confidential and may be legally 
privileged. If you are not the intended recipient of this message, any use, 
disclosure, copying, distribution or any action taken in reliance on it is 
prohibited and may be unlawful. If you have received this message in error, 
please notify the sender immediately by return email and delete this message 
and any copies from your computer and network. WGSN does not warrant that this 
email and any attachments are free from viruses and accepts no liability for 
any loss resulting from infected email transmissions.

WGSN reserves the right to monitor all email through its networks. Any views 
expressed may be those of the originator and not necessarily of WGSN. WGSN is 
powered by Top Right Group<http://www.topright-group.com>, which transforms 
knowledge businesses to deliver exceptional performance.

Please be advised all phone calls may be recorded for training and quality 
purposes and by accepting and/or making calls from and/or to us you acknowledge 
and agree to calls being recorded.

WGSN Limited, Company number 4858491

registered address:

Top Right Group Limited, The Prow, 1 Wilder Walk, London W1B 5AP

WGSN Inc., tax ID 04-3851246, registered office c/o National Registered Agents, 
Inc., 160 Greentree Drive, Suite 101, Dover DE 19904, United States

4C Serviços de Informação Ltda., CNPJ/MF (Taxpayer's Register): 
15.536.968/0001-04, Address: Avenida Nove de Julho, 5966, Loja, CEP 01406-200, 
Jardim Europa, São Paulo

4C Business Information Consulting (Shanghai) Co., Ltd, 富新商务信息咨询(上海)有限公司, 
registered address Unit 4810/4811, 48/F Tower 1, Grand Gateway, 1 Hong Qiao 
Road, Xuhui District, Shanghai

Reply via email to