skttl
08/15/2023, 5:23 AMD_Inventor
08/15/2023, 6:21 AMD_Inventor
08/15/2023, 6:22 AMnzdev
08/15/2023, 6:25 AMskttl
08/15/2023, 6:25 AMnzdev
08/15/2023, 6:27 AMskttl
08/15/2023, 6:43 AMnzdev
08/15/2023, 6:46 AMnzdev
08/15/2023, 6:49 AMnzdev
08/15/2023, 6:49 AMskttl
08/15/2023, 6:54 AMnzdev
08/15/2023, 7:34 AMnzdev
08/15/2023, 7:35 AMnzdev
08/15/2023, 7:36 AMnzdev
08/15/2023, 7:37 AMnzdev
08/15/2023, 7:37 AMnzdev
08/15/2023, 7:38 AMskttl
08/15/2023, 8:19 AMcs
public class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
public void Configure(string? name, LuceneDirectoryIndexOptions options)
{
if (name?.Equals("ExternalIndex") is true)
{
var facetFields = new List<string>
{...}; // all the fields names
var facetsConfig = new FacetsConfig();
foreach (var field in facetFields)
{
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(field, FieldDefinitionTypes.FacetTaxonomyFullText));
}
options.FacetsConfig = facetsConfig;
options.UseTaxonomyIndex = true;
}
}
public void Configure(LuceneDirectoryIndexOptions options) => Configure(string.Empty, options);
}
But, when I try to search, it breaks saying NotSupportedException: Directory Factory does not implement CreateTaxonomyDirectory
It seems like it breaks already when getting the searcher from the index.nzdev
08/15/2023, 8:20 AMskttl
08/15/2023, 8:20 AMnzdev
08/15/2023, 8:20 AMnzdev
08/15/2023, 8:22 AMnzdev
08/15/2023, 8:25 AMnzdev
08/15/2023, 8:27 AMnzdev
08/15/2023, 8:27 AMskttl
08/15/2023, 8:29 AMnzdev
08/15/2023, 8:29 AMnzdev
08/15/2023, 8:32 AMskttl
08/15/2023, 8:36 AMnzdev
08/15/2023, 8:37 AMnzdev
08/15/2023, 8:37 AMnzdev
08/15/2023, 8:40 AMskttl
08/15/2023, 8:55 AMskttl
08/15/2023, 8:55 AMskttl
08/15/2023, 10:55 AM.GroupedOr(new [] { "myFacetField"}, new[] { "Facet1", "facet2" }).WithFacets(facets => facets.FacetString("myFacetField"))
I only get the already selected facets back on result.GetFacet("myFacetField")
nzdev
08/15/2023, 12:25 PMskttl
08/15/2023, 12:45 PMnzdev
08/15/2023, 12:46 PMskttl
08/15/2023, 12:54 PMJemayn
08/25/2023, 1:16 PMD_Inventor
08/25/2023, 2:02 PMNikcio
08/25/2023, 2:31 PMJemayn
08/28/2023, 7:10 AMD_Inventor
08/28/2023, 7:20 AMD_Inventor
08/28/2023, 7:20 AMJemayn
08/28/2023, 12:41 PMNikcio
08/28/2023, 8:32 PMJemayn
08/29/2023, 7:18 AMJemayn
08/30/2023, 9:58 AMquery.WithFacets(facets => facets.FacetString($"productMarkings_{culture}", c => c.MaxCount(200)));
andrewmckaskill
09/01/2023, 5:17 PMnzdev
09/13/2023, 2:43 AMJemayn
09/13/2023, 8:07 AMJemayn
09/13/2023, 12:16 PMnzdev
09/13/2023, 12:32 PMBjarne Fyrstenborg
09/13/2023, 2:06 PMFacet()
method, but these.Bjarne Fyrstenborg
09/13/2023, 2:12 PMFacet()
https://github.com/Shazwazza/Examine/pull/311/files#diff-fb375fe299a36165510b574c9ccb6e287eb49ccafcc5b2e05df0d367d5425df0
But now FacetString()
, FacetDoubleRange()
, FacetFloatRange()
and FacetLongRange()
.Bjarne Fyrstenborg
09/13/2023, 2:29 PMNikcio
09/13/2023, 4:39 PMNikcio
09/13/2023, 4:42 PMBjarne Fyrstenborg
09/14/2023, 6:56 AMFacetIntegerRange()
.. when we have FacetInteger
? or FacetDateTimeRange()
... when we have FacetDateTime()
?
Not sure if facets are supported on datetime as well .. and I guess with facets on integer the double, float or long facet range method can be used.Bjarne Fyrstenborg
09/14/2023, 7:22 AMExternalIndex
I think it is something like this, but when I set UseTaxonomyIndex
here, it fails on startup.Jemayn
09/14/2023, 7:37 AMBjarne Fyrstenborg
09/14/2023, 8:14 AMpublic sealed class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
public void Configure(string name, LuceneDirectoryIndexOptions options)
{
switch (name)
{
case "ExternalIndex":
var priceFields = new List<string>
{
"price"
};
// Create a config
var facetsConfig = new FacetsConfig();
foreach (var field in priceFields)
{
//options.FieldDefinitions.AddOrUpdate(new FieldDefinition(field, FieldDefinitionTypes.FacetDouble));
facetsConfig.SetIndexFieldName(field, $"facet_{field}");
}
options.FacetsConfig = facetsConfig;
//options.UseTaxonomyIndex = true;
break;
}
}
public void Configure(LuceneDirectoryIndexOptions options)
=> Configure(string.Empty, options);
}
However it still seems to break when I set UseTaxonomyIndex
When the AddOrUpdate()
on the existing "price" field in Umbraco Commerce, it lost this field in index.
I guess it is because the price property is indexed like this by default, when the guid is reference to the currency.Bjarne Fyrstenborg
09/14/2023, 8:34 AMTransformIndexValues
:
if (e.ValueSet.Values.ContainsKey("price"))
{
var prices = JsonConvert.DeserializeObject<Dictionary<Guid, string>>(e.ValueSet.GetValue("price").ToString());
foreach (var price in prices)
{
var currency = _currencyService.GetCurrency(price.Key);
values.Add($"price_{currency.Code}", new[] { price.Value });
}
}
and updated to this:
public void Configure(string name, LuceneDirectoryIndexOptions options)
{
switch (name)
{
case "ExternalIndex":
var priceFields = new List<string>
{
"price_GBP"
};
// Create a config
var facetsConfig = new FacetsConfig();
foreach (var field in priceFields)
{
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(field, FieldDefinitionTypes.FacetDouble));
facetsConfig.SetIndexFieldName(field, $"facet_{field}");
}
options.FacetsConfig = facetsConfig;
//options.UseTaxonomyIndex = true;
break;
}
}
Bjarne Fyrstenborg
09/14/2023, 8:39 AMValue
property to has value 0 here?nzdev
09/14/2023, 8:43 AMnzdev
09/14/2023, 8:44 AMnzdev
09/14/2023, 8:45 AMnzdev
09/14/2023, 8:48 AMNikcio
09/14/2023, 9:08 AMBjarne Fyrstenborg
09/14/2023, 9:09 AMBjarne Fyrstenborg
09/14/2023, 9:13 AMExternalIndex
by default as the products are based on Umbraco nodes.
I think the price fields need to be splitted into separate fields to make it work with facets:
https://github.com/umbraco/Umbraco.Commerce.DemoStore/pull/2Bjarne Fyrstenborg
09/14/2023, 9:19 AMDoubleRange()
.. should minInclusive
and maxInclusive
be true
be default like it is with RangeQuery<T>()
?
query.And().RangeQuery<long>(new[] { "myField" }, 0, 10);
Bjarne Fyrstenborg
09/14/2023, 9:33 AMpublic sealed class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
public void Configure(string name, LuceneDirectoryIndexOptions options)
{
switch (name)
{
case Constants.UmbracoIndexes.ExternalIndexName:
var priceFields = new List<string>
{
"price_GBP"
};
// Create a config
var facetsConfig = new FacetsConfig();
foreach (var field in priceFields)
{
options.FieldDefinitions.TryAdd(new FieldDefinition(field, FieldDefinitionTypes.FacetDouble));
facetsConfig.SetIndexFieldName(field, $"facet_{field}");
}
options.FacetsConfig = facetsConfig;
//options.UseTaxonomyIndex = true;
break;
}
}
public void Configure(LuceneDirectoryIndexOptions options)
=> Configure(string.Empty, options);
}
nzdev
09/14/2023, 9:35 AMnzdev
09/14/2023, 10:03 AMnzdev
09/14/2023, 10:06 AMnzdev
09/14/2023, 10:11 AMnzdev
09/14/2023, 10:13 AMnzdev
09/14/2023, 10:14 AMNikcio
09/14/2023, 5:34 PMBjarne Fyrstenborg
09/14/2023, 6:44 PMBjarne Fyrstenborg
09/25/2023, 9:46 AMFacetResult
is there any way to get the label/field/alias?
var results = query.OrderBy(new SortableField("name", SortType.String))
.WithFacets(facets => facets
.FacetLongRange("isGiftCard", new Int64Range[] {
new Int64Range("no", 0, true, 1, false),
new Int64Range("yes", 0, false, 1, true)
})
.FacetDoubleRange("price_GBP", new DoubleRange[] {
new DoubleRange("0-10", 0, true, 10, true),
new DoubleRange("11-20", 11, true, 20, true),
new DoubleRange("20-30", 21, true, 30, true)
})) // Get facets of the price field
.Execute(QueryOptions.SkipTake(pageSize * (page - 1), pageSize));
IEnumerable<IFacetResult> facets = results.GetFacets();
In the model it cast to `IEnumerable`:Bjarne Fyrstenborg
09/25/2023, 11:26 AMprivate IEnumerable<SearchFacetGroup> MapFacets(IList<Ucommerce.Search.Facets.Facet> facets)
{
var mappedFacets = facets
.Select(x => new SearchFacetGroup()
{
Name = GetFacetName(x),
Facets = x.FacetValues.Select(f => new SearchFacet()
{
Count = f.Count,
Name = f.Value
})
.OrderBy(f => f.Name)
});
return mappedFacets;
}
Bjarne Fyrstenborg
09/25/2023, 11:33 AMFacetResult
it doesn't seem we can tell which field it is related to? Or am I missing something? 😄Bjarne Fyrstenborg
09/25/2023, 12:29 PMGetFacets()
it seems I can't find which are related to isGiftCard
and price_GBP
... except I maybe can rely on index in collection?Bjarne Fyrstenborg
09/25/2023, 12:47 PMValue
property on IFacetValue
which is the occurrence, but wouldn't Hits
or Count
make more sense?
Not sure if there's a specific reason the type is float
(decimal value) instead of int
(without decimals)?Nikcio
09/25/2023, 2:41 PMNikcio
09/25/2023, 2:44 PMNikcio
09/25/2023, 2:51 PMBjarne Fyrstenborg
09/26/2023, 10:35 AMisGiftCard
Bjarne Fyrstenborg
09/26/2023, 10:37 AMBjarne Fyrstenborg
09/26/2023, 10:38 AMNikcio
09/26/2023, 2:03 PMBjarne Fyrstenborg
09/27/2023, 6:51 AMFacetString()
should there be a way to specify label for each value as for the ranges?
For example the field may store 0/1, but in frontend one may want "True/False", "Yes/No".
var results = query.OrderBy(new SortableField("name", SortType.String))
.WithFacets(facets => facets
.FacetString("isGiftCard", null, new[] { "1" })
//.FacetLongRange("isGiftCard", new Int64Range[] {
// new Int64Range("no", 0, true, 1, false),
// new Int64Range("yes", 0, false, 1, true)
//})
.FacetDoubleRange("price_GBP", new DoubleRange[] {
new DoubleRange("0-10", 0, true, 10, true),
new DoubleRange("11-20", 11, true, 20, true),
new DoubleRange("20-30", 21, true, 30, true),
new DoubleRange("30-40", 31, true, 40, true),
new DoubleRange("40-50", 41, true, 50, true)
})) // Get facets of the price field
.Execute(QueryOptions.SkipTake(0, 1000));
var facets = results.GetFacets();
https://cdn.discordapp.com/attachments/1140878433157652520/1156483133068300378/image.png?ex=65152259&is=6513d0d9&hm=305ef59e08714eecb97b1cb3191c7b745ae4a082060f9885cff7a1dd40a814e6&Bjarne Fyrstenborg
09/29/2023, 7:27 AMExternalIndex
with eventually changes in Umbraco core? Sure we can add a new index, but it would basically be the same data which already exists in ExternalIndex
and since Umbraco Commerce is based on product/content nodes and therefore use ExternalIndex
.
Also if one wanted to use taxonomy faceting on data in content tree, e.g. employees... or it could be media listed on a Press page with options to filter these.nzdev
09/29/2023, 11:51 AMnzdev
09/29/2023, 11:53 AMRosen Petrov
10/02/2023, 6:38 AMRosen Petrov
10/02/2023, 12:40 PMD_Inventor
10/02/2023, 12:42 PMRosen Petrov
08/13/2024, 11:13 AMRosen Petrov
08/13/2024, 12:31 PM