Posted on 08/05/2017 18:52:22
Ok so ive tried using term facets. I ran into some problems though..
I create a simple query where string param "rId" should "Equal" the string field in my index called RiderId
I then create a term facet for this field in the xml to get around the "more than 2048 terms" error
I use the facet in a querypublisher template that i called qptemp
I send params to the template like this: /qptemp?rId=1234
i get this error:
System.NullReferenceException: Object reference not set to an instance of an object.
at Lucene.Net.Search.BooleanQuery.Rewrite(IndexReader reader) in d:\Lucene.Net\FullRepo\trunk\src\core\Search\BooleanQuery.cs:line 482
at Lucene.Net.Search.IndexSearcher.Rewrite(Query original) in d:\Lucene.Net\FullRepo\trunk\src\core\Search\IndexSearcher.cs:line 302
at Lucene.Net.Search.Query.Weight(Searcher searcher) in d:\Lucene.Net\FullRepo\trunk\src\core\Search\Query.cs:line 96
at Lucene.Net.Search.Searcher.Search(Query query, Filter filter, Int32 n, Sort sort) in d:\Lucene.Net\FullRepo\trunk\src\core\Search\Searcher.cs:line 57
at Dynamicweb.Indexing.Lucene.LuceneIndexProvider.FillFacetFieldTerms(Facet facet, FieldDefinitionBase field, IndexReader reader, Query searchQuery, QuerySettings settings, FacetGroupResult facetsResult, IList`1 exceptions)
at Dynamicweb.Indexing.Lucene.LuceneIndexProvider.DoFacetSearch(IFacetGroup facets, FieldDefinitionBase[] fields, IndexReader reader, IQuery query, QuerySettings settings, Query originalQuery, IList`1 exceptions)
at Dynamicweb.Indexing.Lucene.LuceneIndexProvider.SearchInternal(IQuery query, QuerySettings settings)
at Dynamicweb.Modules.QueryPublisher.Frontend.GetContent()
if i instead use another facet created for horses then it works when i query for a rider (it shows the horses related to the rider).. if i query for a horse then it breaks again.. so it seems i cant query for a field that has a term facet on the page ??
---------------------------------------------
in other words.. this works:
/qptemp?rId=1234
&
<?xml version="1.0" encoding="utf-8"?>
<Query>
<Settings />
<Source Repository="MainRepo" Item="Results.index" Type="Dynamicweb.Indexing.Queries.IndexQueryProvider, Dynamicweb.Indexing" />
<Parameters>
<Parameter Name="rId" Type="System.String" DefaultValue="" />
<Parameter Name="hId" Type="System.String" DefaultValue="" />
</Parameters>
<Expressions>
<BinaryExpression Operator="Equal">
<Left>
<FieldExpression Field="RiderId" />
</Left>
<Right>
<ParameterExpression Name="rId" />
</Right>
</BinaryExpression>
<BinaryExpression Operator="Equal">
<Left>
<FieldExpression Field="HorseId" />
</Left>
<Right>
<ParameterExpression Name="hId" />
</Right>
</BinaryExpression>
</Expressions>
</Query>
&
<?xml version="1.0" encoding="utf-8"?>
<Facets>
<Settings />
<Source Repository="MainRepo" Item="resq.query" />
<Facet Name="Horse" Type="Term" Field="HorseId" QueryParameter="hId" />
</Facets>
-------------------------------------------------------------------------------------------------
and this does NOT:
/qptemp?rId=1234
&
<same query xml>
&
<?xml version="1.0" encoding="utf-8"?>
<Facets>
<Settings />
<Source Repository="MainRepo" Item="resq.query" />
<Facet Name="Rider" Type="Term" Field="RiderId" QueryParameter="rId" />
</Facets>
-------------------------------------------------------------------------------------------------
also this works but is kinda useless for our usecase:
/qptemp?rId=1234&hId=5555 <-- OBS!
&
<same query xml>
&
<?xml version="1.0" encoding="utf-8"?>
<Facets>
<Settings />
<Source Repository="MainRepo" Item="resq.query" />
<Facet Name="Horse" Type="Term" Field="HorseId" QueryParameter="hId" />
<Facet Name="Rider" Type="Term" Field="RiderId" QueryParameter="rId" />
</Facets>
-------------------------------------------------------------------------------------------------
so how can we have 2 term facets on same page and only query 1 of them ? (the one that gets queried would only have a single value in it.. -> aka hidden)
//Martin