Yesterday I finally managed to get my own XSLTsearch working. But then I discovered something strange on my results page: the resultingsentence (with the query inside) isn't always shown, though the header above always is.
Example:
PAGENAME: VACANCIES
HEADER:WERKEN BIJ EEN BEDRIJF
BODYTEXT: Timmerman gezocht! Wij zijn op zoek naar een timmerman met het motto 'wat mijn ogen zien, maken mijn handen!'
Whenever I type in 'timmerman' (dutch for 'carpenter', by the way), I DO get the PAGE this text is on ('Vacancies') and the HEADER text is shown, but NOT the BodyText, in which my query ('timmerman') should be highlighted.
However, when I type in a word from the header like 'werken' (dutch for 'working'), I get the same result, but then with the query inside the sentence highlighted like so: 'Werken bij een bedrijf', just the way I wanted!
What do I have to do to get the same results for my BodyText? At this moment, not only my query isn't highlighted; the entire BodyText isn't displayed!
Okay, so I'm searching Google for this, and I'm finding that it has something to do with "context: unavailable". The problem here is, that all solutions for this matter are focussed on XSLTsearch 2.8, but since I'm using 3.0, this isn't of any help to me. :-(
Any ideas how I can solve this problem? I already checked my searchFields and previewFields, and I made them have the same values already.
In the solutions for 2.8 I'm being told to replace some lines of code containing 'displayField' with some bugfixed code, but since I'm using 3.0 there's nothing like a 'displayField' in my XSLT file. :-(
I have brought both my searchFields and my previewFields down to just 'tekstpagina_tekst' (textpage_text), and suddenly it's all working fine. But as soon as I add the header 'tekstpagina_titel' (textpage_title) to it, I get the old 'context: unavailable' error.
I looks like you're using the same entries in both the searchFields= and previewFields= parameters. That's okay, but be aware that the order of these fields determines how XSLTsearch behaves.
You want the searchFields= to have the most important fields listed first (a search result found in the first property should be much more relevant than if found in the second or third). The order of the properties listed in the searchFields= parameter will effect the ranking of search results.
In general, you'll want the previewFields= parameters to NOT be the same as the searchFields because not all of those fields you search within are relevant to be shown as part of the preview text. For instance, if you search within an seoMetaKeywords property you wouldn't want to show that list of keywords as the summary preview in the search results. You want to be careful which fields you use for the previewFields= therefore. And typically you'll end up listing them in about the reverse order of the searchFields.
It is more important to get a good search result ranking and to show some preview info from the page than to always strive to get the exact context of every search term in the preview since what determines a good search result match doesn't necessarily correpsond to the preview field.
Another option is to not use the previewType="CONTEXT" option but to use previewType="Beginning". Then you'd include only fields that contain helpful text for the preview (bodyText, for instance). Again, the order of the properties is important because the first property with text will be used for the preview.
I have brought both the values of searchFields and previewFields down to just 'tekstpagina_tekst' (textpage_text), and suddenly it's all working fine. But as soon as I add the header 'tekstpagina_titel' (textpage_title) to it, I get the old 'context: unavailable' error.
Thanks for your extended explaination! I'm starting to learn how XSLTsearch works indeed, and tried your solution: to reverse the order of the values in previewFields. So this is my new code:
To come back to my example of the 'timmerman' query: when I now search for 'timmerman' it shows up highlighted! But when I then try a word from the header, like 'werken', my bodytext shows up instead of the header, with no highlights at all.
But if I'm understanding you the right way, I just have to pick one of those two options: or the header will be shown with highlights, or the bodytext. Correct?
I admit I've kind of lost track of things a bit here. Perhaps because I don't know anything but English ;)
You said above that you have the following:
PAGENAME: VACANCIES HEADER:WERKEN BIJ EEN BEDRIJF BODYTEXT: Timmerman gezocht! Wij zijn op zoek naar een timmerman met het motto 'wat mijn ogen zien, maken mijn handen!'
But your macro shows fields called tekstpagina_titel, tekstpagina_tekst. What do those fields correspond to in your example?
I assume the PAGENAME = @nodeName in the macro, though you aren't searching that field.
Firstly I apologise: I should just be using plain English (but was lazy and pasted my Dutch text literally on this forum), so this is a learning moment for me; ;-)
You're right: HEADER is tekstpagina_titel (textpage_title) and BODYTEXT is tekstpagina_tekst (textpage_text).
Oh, and frankly I don't use pagename (or nodename), it's just to explain on which page the title + text are used, that's all. ;-)
When you search for a word that appears in the bodyText the results will show the bodyText field in the preview. Because the search term appears within the first characters of the bodyText field it will be highlighted (if the search term appeared later in the bodyText the term wouldn't appear or be highlighted but that won't change the pages returned by the search nor the ranking of the search. The preview is just to help the website visitor know if the page in the results is worth clicking to see more).
When you search for a work that appears in the header the results will show the bodyText field in the preview. Why? Because you asked for it to be the primary preview field. Only if the document type of the search result doesn't have a bodyText field will the next preview field be used.
Highlights on results page
Yesterday I finally managed to get my own XSLTsearch working. But then I discovered something strange on my results page: the resulting sentence (with the query inside) isn't always shown, though the header above always is.
Example:
PAGENAME: VACANCIES
HEADER:WERKEN BIJ EEN BEDRIJF
BODYTEXT: Timmerman gezocht!
Wij zijn op zoek naar een timmerman met het motto 'wat mijn ogen zien, maken mijn handen!'
Whenever I type in 'timmerman' (dutch for 'carpenter', by the way), I DO get the PAGE this text is on ('Vacancies') and the HEADER text is shown, but NOT the BodyText, in which my query ('timmerman') should be highlighted.
However, when I type in a word from the header like 'werken' (dutch for 'working'), I get the same result, but then with the query inside the sentence highlighted like so: 'Werken bij een bedrijf', just the way I wanted!
What do I have to do to get the same results for my BodyText? At this moment, not only my query isn't highlighted; the entire BodyText isn't displayed!
Thanks in advance ;-)
Okay, so I'm searching Google for this, and I'm finding that it has something to do with "context: unavailable". The problem here is, that all solutions for this matter are focussed on XSLTsearch 2.8, but since I'm using 3.0, this isn't of any help to me. :-(
Any ideas how I can solve this problem? I already checked my searchFields and previewFields, and I made them have the same values already.
In the solutions for 2.8 I'm being told to replace some lines of code containing 'displayField' with some bugfixed code, but since I'm using 3.0 there's nothing like a 'displayField' in my XSLT file. :-(
This is my line of code for XSLTsearch inside my template:
<umbraco:Macro source="1052" searchFields="adresgegevens, tekstpagina_titel, tekstpagina_tekst, proj_locatie1, proj_locatie2, proj_locatie3, inl_titel, inl_tekst, proj_tekst1, proj_tekst2, proj_tekst3" previewFields="adresgegevens, tekstpagina_titel, tekstpagina_tekst, proj_locatie1, proj_locatie2, proj_locatie3, inl_titel, inl_tekst, proj_tekst1, proj_tekst2, proj_tekst3" searchBoxLocation="NONE" previewType="CONTEXT" resultsPerPage="10" previewChars="255" showPageRange="1" showOrdinals="1" showScores="0" showStats="0" Alias="XSLTsearch" runat="server"></umbraco:Macro>
I have brought both my searchFields and my previewFields down to just 'tekstpagina_tekst' (textpage_text), and suddenly it's all working fine.
But as soon as I add the header 'tekstpagina_titel' (textpage_title) to it, I get the old 'context: unavailable' error.
Hi, Peter,
I looks like you're using the same entries in both the searchFields= and previewFields= parameters. That's okay, but be aware that the order of these fields determines how XSLTsearch behaves.
You want the searchFields= to have the most important fields listed first (a search result found in the first property should be much more relevant than if found in the second or third). The order of the properties listed in the searchFields= parameter will effect the ranking of search results.
In general, you'll want the previewFields= parameters to NOT be the same as the searchFields because not all of those fields you search within are relevant to be shown as part of the preview text. For instance, if you search within an seoMetaKeywords property you wouldn't want to show that list of keywords as the summary preview in the search results. You want to be careful which fields you use for the previewFields= therefore. And typically you'll end up listing them in about the reverse order of the searchFields.
It is more important to get a good search result ranking and to show some preview info from the page than to always strive to get the exact context of every search term in the preview since what determines a good search result match doesn't necessarily correpsond to the preview field.
Another option is to not use the previewType="CONTEXT" option but to use previewType="Beginning". Then you'd include only fields that contain helpful text for the preview (bodyText, for instance). Again, the order of the properties is important because the first property with text will be used for the preview.
Hope this helps explain how XSLTsearch works.
cheers,
doug.
I have brought both the values of searchFields and previewFields down to just 'tekstpagina_tekst' (textpage_text), and suddenly it's all working fine.
But as soon as I add the header 'tekstpagina_titel' (textpage_title) to it, I get the old 'context: unavailable' error.
Hi Doug,
Thanks for your extended explaination! I'm starting to learn how XSLTsearch works indeed, and tried your solution: to reverse the order of the values in previewFields. So this is my new code:
<umbraco:Macro source="1052" searchFields="tekstpagina_titel, tekstpagina_tekst" previewFields="tekstpagina_tekst, tekstpagina_titel" searchBoxLocation="NONE" previewType="BEGINNING" resultsPerPage="10" previewChars="255" showPageRange="1" showOrdinals="1" showScores="0" showStats="0" Alias="XSLTsearch" runat="server"></umbraco:Macro>
To come back to my example of the 'timmerman' query: when I now search for 'timmerman' it shows up highlighted! But when I then try a word from the header, like 'werken', my bodytext shows up instead of the header, with no highlights at all.
But if I'm understanding you the right way, I just have to pick one of those two options: or the header will be shown with highlights, or the bodytext. Correct?
Hi, Peter,
I admit I've kind of lost track of things a bit here. Perhaps because I don't know anything but English ;)
You said above that you have the following:
PAGENAME: VACANCIES
HEADER:WERKEN BIJ EEN BEDRIJF
BODYTEXT: Timmerman gezocht! Wij zijn op zoek naar een timmerman met het motto 'wat mijn ogen zien, maken mijn handen!'
But your macro shows fields called tekstpagina_titel, tekstpagina_tekst. What do those fields correspond to in your example?
I assume the PAGENAME = @nodeName in the macro, though you aren't searching that field.
Does HEADER = tekstpagina_titel ?
Does BODYTEXT = tekstpagina_tekst ?
cheers,
doug.
Hi Doug,
Firstly I apologise: I should just be using plain English (but was lazy and pasted my Dutch text literally on this forum), so this is a learning moment for me; ;-)
You're right: HEADER is tekstpagina_titel (textpage_title) and BODYTEXT is tekstpagina_tekst (textpage_text).
Oh, and frankly I don't use pagename (or nodename), it's just to explain on which page the title + text are used, that's all. ;-)
I'll be more clear next time!
p
I'm the one who is lingually illiterate! No need to apologize.
Okay, I think I understand what you're saying and here's what happens in various situations when you have the following settings for your macro:
searchFields="header, bodyText" previewFields="bodyText, header"
When you search for a word that appears in the bodyText the results will show the bodyText field in the preview. Because the search term appears within the first characters of the bodyText field it will be highlighted (if the search term appeared later in the bodyText the term wouldn't appear or be highlighted but that won't change the pages returned by the search nor the ranking of the search. The preview is just to help the website visitor know if the page in the results is worth clicking to see more).
When you search for a work that appears in the header the results will show the bodyText field in the preview. Why? Because you asked for it to be the primary preview field. Only if the document type of the search result doesn't have a bodyText field will the next preview field be used.
Hope this helps.
cheers,
doug.
Hi Doug,
Thanks, now I finally know how this part of XSLTsearch works.
Thanks again!
is working on a reply...