Closed craigs100 closed 1 year ago
Hi Craig
Thanks for your feedback - any chance you could paste your configuration, and you search code? Just to figure out how it ends up hitting TooManyClauses
.
For the paging, are you sure that the results you get on ?p=2
is actually the second page of results?
Hi Søren,
I'm afraid I gave up once I saw that the summary text wasn't anything I recognised and rolled my own. However, to be helpful, here's some data from my Git history and some observations:
Config in Startup.cs:-
{
o.Enabled = true; // set your own config here.
o.DisallowedPropertyAliases = new List<string>() { "sitemap" };
});
Search Page:-
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@using Our.Umbraco.FullTextSearch.Interfaces
@using System.Globalization
@using Our.Umbraco.FullTextSearch.Models
@inject Our.Umbraco.FullTextSearch.Helpers.FullTextSearchHelper FullTextSearchHelper
@{
Layout = "Master.cshtml";
var searchTerm = Context.Request.Query["q"].FirstOrDefault() ?? string.Empty;
IFullTextSearchResult searchResult = null;
string culture = CultureInfo.CurrentCulture.ToString().ToLower();
if (!string.IsNullOrEmpty(searchTerm)) {
var searcher = new Search(searchTerm).SetCulture(culture).RemoveAllowedContentTypes("searchPage");
searchResult = FullTextSearchHelper.Search(searcher);
}
}
<div>
<div>
<div>
@await Html.GetBlockGridHtmlAsync(Model.MainContent)
</div>
<section class="search-results">
<div class="container">
<div class="text">
<h3>@Umbraco.GetDictionaryValue("Search Label")</h3>
<form action="#" method="GET" class="search-form">
<input type="text" name="q" placeholder="@Umbraco.GetDictionaryValue("Search Placeholder")" value="@searchTerm"/>
<input type="submit" class="btn-line" value="@Umbraco.GetDictionaryValue("Search Label")"/>
</form>
@if (searchResult != null) {
<ul>
@foreach (var result in searchResult.Results) {
<li>
<a href="@result.Content.Url()">@result.Title</a>
<p>
@result.Summary
</p>
<small>
@*@Umbraco.GetDictionaryValue("URL"): @result.Content.Url()<br>
@Umbraco.GetDictionaryValue("ID"): @result.Id<br/>*@
@Umbraco.GetDictionaryValue("Last Updated"): @(result.Content.UpdateDate)<br>
@Umbraco.GetDictionaryValue("Score"): @result.Score
</small>
</li>
}
</ul>
<div>@Umbraco.GetDictionaryValue("Total Results"): @searchResult.TotalResults</div>
if (searchResult.CurrentPage > 1) {
<a href="?q=@Context.Request.Query["q"].ToString()&p=@(searchResult.CurrentPage - 1)">Previous page</a>
}
if (searchResult.CurrentPage < searchResult.TotalPages) {
<a href="?q=@Context.Request.Query["q"].ToString()&p=@(searchResult.CurrentPage + 1)">Next page</a>
}
}
</div>
</div>
</section>
</div>
</div>```
The site is a 3 language site built with a GeneralPage docType containing a blocklist that holds all the content. What I was finding was the the summary text was the same under every page link (screenshot attached). It was basically the text from the navigation header.
As for paging, it reported 150 results with the default page size of 10. If I added &p=2 to the url then I got the same results page back every time, whether it was p=2 or 3, etc. I'm guessing that the current page is the 1st page of the block asked for (i.e. p2 = 21-30 etc) but what was displayed was the first page of all the results, not the 10 requested. Anyway, I got frustrated and rolled my own in the end. I just used one I build previously but needed to find out how to add the culture in. Once that was done the rest was easy.
Anyway, I hope this helps. I suspect it's the blockgrid that's done it, plus not being able to select the docTypes you want to include, so it quickly gets overwhelmed.
Cheers.
Hi Craig
Once again, thank you for trying out the package :)
Regarding the paging, you need to specify which page you want in the Search
method. There is an example in "the clean way" in the docs.
For the max clauses error, I'm still unsure what caused this. If you set the logging level to debug (in your appsettings - you can make an override for only Our.Umbraco.FullTextSearch
, so you don't get tons of debug logs from everything else :)), it should log the query it produces. That could be helpful in order to figure out what causes the apparently too many clauses.
I had this working after a fashion on a multi-lingual site V10.6.1. It's fine for a single word search but any more than that and I end up with :-
TooManyClauses: maxClauseCount is set to 1024
From my reading it appears to be due to queries being built for every property on every docType. I don't see a way to tell the search which fields on which docTypes to search.
Also paging is an issue, maybe an explainer in the docs as to how you envisioned it working? We need to be able to construct the likes of :-
<prev 1 2 3 4 next>
I'm always seeing page 1 of 25 even when p=2. I'd really like to use this package if I can. The site is mainly built with BlockGrids on one docType and a few other docTypes that I wouldn't need to search. Not sure if that's a factor tbh.Thanks.