Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Implementing SearchUnit in JavaScript - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
DMacy
#1 Posted : Wednesday, August 24, 2022 5:00:26 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
I have successfully implemented SearchUnit in ASP.NET with VB.NET. That part is working fine.

Now I need to have a search box and display results using JavaScript. Can you point me to some sample code for customizing your JavaScript functions?

Thanks!
Jim
#2 Posted : Wednesday, August 24, 2022 9:05:31 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
I'm not sure what you're looking for exactly, but if you open the help and go to Searching an Index -> Using AJAX and Javascript.... you will see how to use it from Javascript.

https://keyoti.com/produ...ch/dotNetWeb/HtmlHelp8/#
-your feedback is helpful to other users, thank you!


DMacy
#3 Posted : Wednesday, August 24, 2022 9:13:59 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
Thanks, Jim!

I need to create a text box and button in a JavaScript function (a button onclick event handler) and then hook them up to SearchUnit so the button triggers a search. I also need to get the results back as an object so I can format them as I wish.

All I've seen so far is putting two divs on a page with the appropriate ids for search box and results. That works, but I need more customization, and I don't see how to do it in JavaScript.
Jim
#4 Posted : Thursday, August 25, 2022 6:18:58 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
How about this;

Code:

    <script src="Keyoti_SearchEngine_Web_Common/SearchUnit.js"></script>
    <link href="Keyoti_SearchEngine_Web_Common/SearchUnit.css" rel="stylesheet" />
    <script type="text/javascript">
        keyotiSearch.setServiceType('core'); //for .NET 5

        function addSearch() {
            var ph = document.getElementById('search_placeholder');
            ph.innerHTML = '<div id="sew_searchBoxControl"></div>';
            keyotiSearchBox.searchBoxControl = KSQ("#sew_searchBoxControl");
            keyotiSearchBox.init();
        }
    </script>
<div class="text-center">
    <input type="button" onclick="addSearch()" value="Add search"/>
    <div id="search_placeholder">

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




and then template the results according to https://keyoti.com/produ...0Usage/BasicSearch.html see the section "Templating The Controls" for SearchResult.

You can do the search programmatically if you really want and then show the results your way without our JS control, but I would discourage it. There is a lot to it and our SearchResult control is designed to work with you setting the design template anyway.

Jim

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


DMacy
#5 Posted : Thursday, August 25, 2022 7:35:11 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
When I add your sample code to the beginning of my page, it works as I would expect. When I put it where I really want it, which is in a popup that is displayed when another button is clicked, it displays the search box, but when the search button is clicked, it says it can't find sew_searchResultControl, even though Inspect Element in Chrome shows it to be there.
Jim
#6 Posted : Thursday, August 25, 2022 8:15:20 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
The sew_searchResultControl is in the popup too? Can you show me more code explaining what is happening?
-your feedback is helpful to other users, thank you!


DMacy
#7 Posted : Thursday, August 25, 2022 8:31:42 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
I was going to update our site so I could show you, but I'm running into problems with the ASP.NET compiler and SearchWebService.asmx. I changed Keyoti2 to Keyoti4 on the first line, but now it's having a problem with the second line. Do I really need to uninstall SearchUnit and revert to the .NET 2 DLLs?
Jim
#8 Posted : Thursday, August 25, 2022 9:29:40 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
If you want to use the asmx you can by calling in JS

keyotiSearch.setServiceType('asmx'); //for .NET 2

That should work with the .NET 4 or .NET 2 DLLs provided the asmx is in the scripts folder.

If you want to use .NET 4 and WCF (default), then the problem is most likely that WCF isn't installed properly on IIS.
-your feedback is helpful to other users, thank you!


DMacy
#9 Posted : Thursday, August 25, 2022 9:35:56 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
I have the asmx file in the same folder as SearchUnit.css and SearchUnit.js. Is that what you mean by the scripts folder?

I don't think the setServiceType statement would make any difference, because the error I'm getting is with the ASP.NET compiler. I've never worked with asmx files before, so I have no idea what's going on.
Jim
#10 Posted : Friday, August 26, 2022 4:01:17 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
My guess, without seeing the error is that you need to open the .asmx and change

<%@ Assembly Name="Keyoti2.SearchEngine.Web, Version=2021.8.21.1221, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e" %>

to

<%@ Assembly Name="Keyoti4.SearchEngine.Web, Version=2021.8.21.1221, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e" %>

don't change the version number, leave it as is.

Sorry it didn't occur to me earlier.


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


DMacy
#11 Posted : Friday, August 26, 2022 12:36:01 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
All of the references in web.config and SearchWebService.asmx are Keyoti4 but version 2017.7.18.904. This suggests that I need to upgrade my whole SearchUnit installation to a new version. Is that correct?
Jim
#12 Posted : Friday, August 26, 2022 4:03:34 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
You can if you like, I'll email you about that. It's not likely the cause of the problem.

Can you show me the error too?

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


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.