Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Filter search on URL path - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
bill
#1 Posted : Thursday, March 15, 2018 6:31:34 PM
Rank: Advanced Member

Groups: Registered

Joined: 2/29/2008
Posts: 43
I'm using Search Unit 6 with the Ajax-based search.

I need to limit a search to a subsection of a web site (e.g., path starts with "/section1/section2/section3".

I don't want to use Content Categories for this scenario because of the hierarchy: a search in section1 should include everything below section1, but you should also be able to search at the section2 level, etc. This would require each level to be assigned to all the categories that its parent is assigned to, which, if nothing else, makes the search results look messy (because a search result would show that it's in "section1/section2/section3, section1/section2, and section1".

Is there a way to filter (client-side) based on the path? Am I better off doing the search on the server side and filtering the results there?
Jim
#2 Posted : Friday, March 16, 2018 12:37:14 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Let's say you have this hierarchy of Sections, eg. number is a section name.

Code:

1000
   |------1100
   |          |-------1110
   |
   |------1200
   |          |-------1210
   |          |           |-----doc1
   |          |-------1220


Which is equivalent to paths like
Code:

1000/1100/1110
1000/1200/1210
1000/1200/1220


Doc1 in that structure is at 1000/1200/1210/doc1, and it's CustomData (see https://keyoti.com/produ.../CustomDataFilters.html) is set to

Code:

Sections=1000,1200,1210


The user chooses to search under Section=1200. Which means that Doc1 should be included in the search.

What you want to do is specify a 'stringlistor' filter (as in above link), with the user's choice of 1200.

This means that the filter engine will look for '1200' in the list specified in 'Sections' in the Custom Data, for each result, if there is a match it is potentially included in the results, if not it's filtered out.


Code:

   

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <link href="/Keyoti_SearchEngine_Web_Common/SearchUnit.css" rel="stylesheet" />
        <script src="/Keyoti_SearchEngine_Web_Common/SearchUnit.js"></script>
    </head>
    <body>
        <div id="sew_searchBoxControl"></div>

        <div id="sew_filterControls">

                <!--Or based checkbox selector for features-->
    <div class="sew_stringOrFilter sew_filterControl">
        <!-- {"FieldName":"Sections", "ControlType":"checkboxes","Label":"Sections:", "Type":"[b]stringlistor[/b]",
                    "Options":[{ "value": "1000" }, { "value": "1100"  }, { "value": "1110"  },
                    { "value": "1200"  }, { "value": "1210"  }], "GetLiveDataFromServer": "false"}-->
    </div>

        </div>

        <div id="sew_searchResultControl"></div>
    </body>
</html>





I haven't actually tried it, but I believe that's what you need. It won't look pretty but you can apply style/layout with CSS I think.

Jim





-your feedback is helpful to other users, thank you!


bill
#3 Posted : Friday, March 16, 2018 1:33:49 AM
Rank: Advanced Member

Groups: Registered

Joined: 2/29/2008
Posts: 43
Thanks, Jim. I see I accidentally dropped a paragraph from my original post--I meant to be asking whether I could do this straight from the URL or whether I needed to add custom data instead. Sounds like I need to add custom data :)

The other part I left out is that I want to set the filter programmatically and not use a filter control. I assume I do this with keyotiCustomDataFilters.setFilterCollection but I'm not clear what to pass in here.
Jim
#4 Posted : Friday, March 16, 2018 4:32:36 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
I don't think you're going to be able to do it without a control, but you could just wrap the control in a display:none DIV, to hide it. Then set the control's value (check boxes) as needed programmatically.
-your feedback is helpful to other users, thank you!


bill
#5 Posted : Friday, March 16, 2018 12:49:39 PM
Rank: Advanced Member

Groups: Registered

Joined: 2/29/2008
Posts: 43
Thanks. I'll look at that, or maybe just do the filtering on the back-end.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.