Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Add ResultItem to search results - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
DMacy
#1 Posted : Thursday, August 24, 2017 8:57:52 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
In the handler for the action Keyoti.SearchEngine.Events.ActionName.ResultItemsFinalized, is it possible to add a ResultItem to the list of search results?

Thanks!

Dan
Jim
#2 Posted : Thursday, August 24, 2017 11:54:58 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Yes I believe you should be able to do that, I know we say you can modify the list (ie sort it, filter it) so I think it should be OK.
-your feedback is helpful to other users, thank you!


DMacy
#3 Posted : Friday, August 25, 2017 2:12:08 AM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
I'll have to try it again. Several weeks ago I tried with a new instance of ResultItem and then adding it to the search results collection, but it failed, and I'm not sure why. What are the required elements to define in the new ResultItem to make it act like it was selected by SearchUnit?
Jim
#4 Posted : Friday, August 25, 2017 6:25:15 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Without sifting through the code I would say Title, Summary, Description, Uri, UriAsStored (I think there's a property called that there), Weight.

If you try again and get an exception let me know what it is please and that will be easier to tell what's wrong.

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


DMacy
#5 Posted : Monday, September 11, 2017 4:20:06 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
I just got time to take a look at this again. I was able to add a ResultItem to the search results. However, it is showing up without any preview text, which I assume probably has to do with this search result not being connected to a document in the index.

I have an index with two translations of the Bible, where each verse of each translation is a separate document. If only one translation of a verse is selected as a search hit (because the word doesn't occur in the other translation's text of that verse), I still want the other translation to be selected as a search hit. Is there another way to accomplish this? Is there a way to add a ResultItem by its Uri in the index? Everything I want to add to the search results is already in the index. I'm not trying to add to the index, just search result items from the index that weren't already selected.

Thanks!
Jim
#6 Posted : Tuesday, September 12, 2017 1:45:33 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
The Summary is generated from the keyword hits in the text, but presumably there are no hits because it's a different language, and even if there were it probably wouldn't work because the summaries are only generated for results that are generated.

Can you set the Summary yourself and is it shown in the result page? If so, I can show you how to pull the Document.Description from the index, so you have some static text to show for the result summary.
-your feedback is helpful to other users, thank you!


DMacy
#7 Posted : Tuesday, September 12, 2017 2:22:03 AM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 136
The third parameter in making a new instance of a ResultItem object is content, and the fifth parameter is summary. I've set both of these to the same string, but it appears to be empty when the item is retrieved for display.

I would be interested in knowing how to get the Document.Description from the index.

Thanks!

Dan
Jim
#8 Posted : Wednesday, September 13, 2017 4:34:02 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Ok, I'm going to get back to you once I know what's wrong.
-your feedback is helpful to other users, thank you!


Jim
#9 Posted : Thursday, September 14, 2017 11:24:50 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Please use this version (you are using v6 right?) then you do it like this

https://www.dropbox.com/...it-Setup-v6.2b.msi?dl=0

Code:

Configuration.CentralEventDispatcher.Action += (object o, ActionEventArgs e) => {
                if (e.ActionData.Name == ActionName.ResultItemsFinalized)
                {
                    Keyoti.SearchEngine.Utils.ResultItemList resultItems = e.ActionData.Data as Keyoti.SearchEngine.Utils.ResultItemList;
                    DocumentIndex idx2 = new DocumentIndex(Configuration);
                    Document doc = idx2.GetDocument(new Uri("http://localhost/temptestfiles/p5.htm"));
                    idx2.Close();
                    ResultItem resultItem = new ResultItem(doc.DocumentRecord, null, 100, null);
                    resultItem.Summary = "my own summary";
                    resultItems.Add(resultItem);
                }
            };



Notes:

Unfortunately it has to load the Document from the DocumentIndex in order to get the document's ID - and that is going to slow down your results somewhat, unless you can avoid it somehow (store the document ID in CustomData somehow?).
Try to write your real code to cache the DocumentIndex object until the end and then close it, rather than how I've done it in my test.
-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.