keyword highlighter functionality

Home Forums Product Support Forums Ajax Search Pro for WordPress Support keyword highlighter functionality

This topic contains 11 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years, 2 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #12077
    kamaltyagi
    kamaltyagi
    Participant

    I wrote to you (the developer) before purchasing this plugin about there being an option to to enable the keyword highlighter functionality to display keyword context from the whole content. I purchased the plugin after you told me that the new release would have this feature, and I have gone through all the options a number of times but I am not able to find where I can enable this.
    Thanks for your time.

    #12082
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    You will find these options on the following places:

    1. Keyword highlighting on the Layout Options -> Results behavior panel: https://i.imgur.com/NctuU6n.png
    2. The description context depth on the Layout Options -> Results layout panel: https://i.imgur.com/XvIqaR6.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12083
    kamaltyagi
    kamaltyagi
    Participant

    Thanks for the reply and clear pointers Ernest.

    I thought that the second one was it, but I was confused because it doesn’t seem to work properly. I have both of the buttons you have specified enabled, but I am not seeing the highlighting in the search results.

    For example, in a post on my site such as http://premadharma.org/the-intelligence-of-a-woodcutter/, the word ‘undisciplined’ occurs in the last sentence of the text. The post is 4800 characters long and I have the “Display the description context?” button on and set to the default of 100000 characters. When I run a search, the result for the page http://premadharma.org/the-intelligence-of-a-woodcutter/ shows up but the result field shows only the post excerpt and does not highlight the word ‘undisciplined’.

    Is there something else I need to do to enable this function?

    In some cases the search results do seem to highlight a specific word that has been search for, but in others they show only the page excerpt or the initial lines of text on the page. How can I set the search function to consistently display and highlight the word that was search for?

    I appreciate your help and I hope I have explained my query clearly.

    #12084
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I’m sorry, my bad, I completely forgot about the fact that the search uses the post excerpt as the primary description field, and the content as the secondary by default.
    Try changing the primary and secondary description fields as following: https://i.imgur.com/p0qVMUb.png
    So the post content becomes the primary source.

    Also, I see you have some longer articles, but all of them mostly contain simple text. I believe you can safely increase the depth value to 500000 (half million) characters, so it covers everything possible: https://i.imgur.com/g2H2o0d.png

    After these changes you should definitely start seeing the highlighted texts as expected 🙂 I hope this helps!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12085
    kamaltyagi
    kamaltyagi
    Participant

    I made the adjustments you suggested, and I do see the desired changes for the most part.

    However, I checked and what I believe is my longest page is nearly 700000 characters long (http://premadharma.org/revealed-truth/). I adjusted the setting in the backend accordingly, and now if I run a search for the phrase “the swan of your heart”, which occurs near the bottom of this page, then the search function does not find the phrase, but if I click on in the front-end settings, “search for exact matches only” then it finds the correct page but it does not highlight the text.

    Is there anything more I can do so that it highlights the exact match?

    #12086
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You are right, that should work as expected, but there is indeed something wrong.

    I have investigated the plugin source, and appears that I have made a mistake in that function regarding exact matching. The problem is, that it only counts for the first word entered, it does not take the full phrase as the context, only the first one.

    Since this is a programatical error, the only way of fixing it is by making a tiny change in the plugin code, in one of the plugin files. I will try to detail which line to change in which file, but if you need help with that, feel free to add a temporary FTP account to the details and I will do it for you.

    Steps:
    1. I always recommend having a backup of everything before making any change, just in case. If you have a back-up proceed to the next step.
    2. Open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-cpt.php file via FTP
    3. Scroll to line 1518, which should be this:

    $_content, $_s[0],

    ..and change that line to this:

    $_content, $s,

    4. Save the file, and it’s done.

    Now, the context finding function should return the context around the whole search phrase. I hope this helps!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12087
    kamaltyagi
    kamaltyagi
    Participant

    I made the change as you described (see screen shot), but I find that now the
    Description (content) length” displayed in the results is not limited to 130 characters as is found in the settings I have and that nearly an entire page worth of text shows up in the result. Also, if I search for “the swan of your heart” with an exact match, the function just stalls with the loader blinking for minutes on end and I have to restart my browser.

    Attachments:
    You must be logged in to view attached files.
    #12089
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You have a syntax error there, the second argument, you have variable $_s and it should be simply $s. That is not correct and it will malfunction.

    $_content, $s,
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12091
    kamaltyagi
    kamaltyagi
    Participant

    I removed the error from the code (my mistake entirely), and now the function nearly works. Still using the “swan of your heart” test, when I search for exact matches, I get the exact match from the bottom of my 700000 character page! Great. This exact phrase occurs in one other piece on the site, however, and the result that shows up for this page, which happens to come first, for some reason does not display the highlighted exact match (this other page is much shorter in length).

    Is there any way to be sure all instances of an exact match get displayed and highlighted in the results?

    #12092
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I have one more possible guess of what might be causing that, but I’m not completely sure. On the “Grand festival..” page the “swan of your heart” text appears within a text which is inside shortcode brackets [ … swan of your heart …]. My guess is that before this text is passed to the context finder, it might be mistakenly ignored as a shortcode, at least this could explain that.

    To resolve this, can you try changing the following option: https://i.imgur.com/RnNDCtK.png
    I have a feeling this will resolve that for all cases.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12093
    kamaltyagi
    kamaltyagi
    Participant

    Yes, that solved the problem and the search displays the two results as desired.

    I greatly appreciate your care for these details.

    #12094
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘keyword highlighter functionality’ is closed to new replies.