Forum Discussion

iftomkins's avatar
11 years ago

How to exclude duplicate topics from search results?

We are using a modified version of the search component. We'd like to exclude topics marked by moderators "duplicate" from showing in the results of this particular search component.

 

How can we filter the search results? Is there way to check if the topic is a duplicate via the API?

 

Here is the code from our customized search component (very similar to functionality of new search box on Lithosphere):

 

<div class="lia-panel-heading-bar-wrapper"><div class="lia-panel-heading-bar"><span class="lia-panel-heading-bar-title ask-a-question-search">${text.format('taplet.askTheExpertTaplet.title')}</span></div></div>

<div class="custom-search-wrapper">
    <div id="custom-search-border">
        <@component id="common.widget.search-form" />
    </div>
    <span class="lia-button-wrapper lia-button-wrapper-primary">
	    <input type="hidden" name="submitContextX" value="Continue"><input type="submit" name="submitContext" id="submitContext" value="${text.format('form.AskAnExpertForm.action.AskTheCommunity.title')}" class="lia-button lia-button-primary lia-button-Continue-action " title="${text.format('form.AskAnExpertForm.action.AskTheCommunity.title')}">
    </span>
</div>

 

4 Replies

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    Hi iftomkins ,

     

    In your community, is "duplicate" a tag, a label or custom tag or metata?

     

    you can write some Javascript, which query an endpoint and append to the search box. In your endpoint, you need to call REST search api and exlude the posts with tag "duplicate".

     

  • iftomkins's avatar
    iftomkins
    Maven
    11 years ago

    Hi HaidongG , thanks for your reply. It's not a tag, it's the status. I've found two references to status in the API docs: status_id and status_key. Do you know which one is preferable to use for this purpose? 

     

    Also, thanks for your description of using an endpoint. I've never used an endpoint before (just custom components), so any additional description of how to go about that would be much appreciated. :)

     

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    Hi iftomkins ,

     

    you are talking about ideas, isn't it?

     

    for status id or status key, i believe that you should use status key, status id is just a number. you can verify the status id and status key via 

    http://community.lithium.com/restapi/vc/boards/id/Lithium_Ideas/message_statuses/available

     

    for find all ideas with key "Duplicate", via

    http://community.lithium.com/restapi/vc/boards/id/Lithium_Ideas/threads/for/message_statuses/key/Duplicate/recent

     

    as you already have your own search box, my suggest was to

    1. write an endpoint which 
      • get the input query from http request parameter
      • use search/messages to find out the message list with the input query
      • iterate the list and remove those messages with status=duplicate
      • output the result as a JSON
    2. write your own "search before post" following this sample code
  • iftomkins's avatar
    iftomkins
    Maven
    11 years ago

    Thank you! Yes, I was referring to ideas, but also to regular topics. To exclude regular topics, I suppose we would start adding "duplicate" tags to each regular topic that is closed for being a duplicate.

     

    I've worked with instant search before, based on that very same script. That's a good suggestion, but I was hoping there would be a more simple way to modify the search action of the default component to exclude closed/duplicate topics. We already have the component build and polished, so I'd prefer to avoid rebuilding it, but will consider that if necessary.

     

    Very helpful infos!