I got a problem regarding returning TotalProducts.
This is my code :
var machineName = Environment.MachineName;
string indexPath = string.Format($"~/App_Data/TEMP/ExamineIndexes/{machineName}/External/Index");
var indexDirectory = FSDirectory.Open(new DirectoryInfo(HttpContext.Current.Server.MapPath(indexPath)));
var searcher = new IndexSearcher(indexDirectory, true);
var masterQuery = new BooleanQuery();
var bed = string.IsNullOrEmpty(model.Bed) ? 0 : Convert.ToInt32(model.Bed);
var bedQuery = ConstructIntRangeQuery("intBeds", 0, bed, bed);
masterQuery.Add(bedQuery, BooleanClause.Occur.MUST);
TopDocs resp = searcher.Search(masterQuery, null, searcher.MaxDoc());
Debug.WriteLine(resp.TotalHits, "Total Products");
resp.TotalHits is always returning 79 products, even if I have 71 total products.
This code is working before in my previous version in Umbraco which is 7.5.6, but when I upgrade it into 7.11.1 is not properly working anymore. It's always returning 79 results, even if I add/delete products.
var bed = string.IsNullOrEmpty(model.Bed) ? "0" : model.Bed;
var searchCriteria = ExamineManager.Instance.DefaultSearchProvider.CreateSearchCriteria(IndexTypes.Content);
var searchQuery = search.NodeTypeAlias("Product");
if (bed != "0")
{
searchQuery .And().Field("bed", Models.bed)
}
var bed = string.IsNullOrEmpty(model.Bed) ? "" : model.Bed;
if (bed == "5")
{
searchQuery.And().Range("bedrooms", 0, Convert.ToInt32(bed), true, true);
// This code is no display.
}
else
{
searchQuery.And().Field("bedrooms", bed);
}
ExamineIndexes not working properly
Hi all,
I got a problem regarding returning TotalProducts.
This is my code :
This code is working before in my previous version in Umbraco which is 7.5.6, but when I upgrade it into 7.11.1 is not properly working anymore. It's always returning 79 results, even if I add/delete products.
Any ideas?
Thanks,
Jin
Hi Jin,
I see you are using your own code. Maybe you can try using the Examine API to do this
https://our.umbraco.com/Documentation/Reference/Searching/Examine/examine-manager
Have you tried rebuilding your index ?
Dave
Hi Dave,
Yes, it's own code, but I am not the one who code it because I am the second developer who handle this site.
I posted about Examine HERE.
Yes, I already rebuilding my indexes in Developer sections, both internal & external, but still not working.
Thanks,
Jin
I've already get it.
I get the nodeId, now how can I get the nodeName and the other fields like title, price, body, etc...
CODE :
Cheers,
Jin
Hi Jin,
To retrieve other fields from the result you can do this ;
Dave
Hi Dave,
Success!!!!
Thanks for your help. Problem solved.
You save my day!
Thanks,
Jin
Hi Dave,
Another problem regarding when user not selected a bedrooms.
This code will return 0, and there is no display.
How can I set the value of model.Bed if users didn't select a bedrooms?
Thanks,
Jin
Maybe don't include the bed "filter" in your search criteria when it's not set by the user.
Dave
Hi Dave,
You mean in my Angular?
Thanks,
Jin
Nope in your c# code. Something like this
Dave
Hi Dave,
Oh,
Thanks to your code, what I did is :
It works well.
Thanks again, for the help!
Cheers,
Jin
Hi Dave,
If users selects 5+ Bedrooms.
How can I query and display all products with more than 5 Bedrooms?
Thanks,
Jin
Hi,
I've tried this code, but it's not working...
Any ideas, for this.
Thanks,
Jin
is working on a reply...