Getting Field values within ISearchResult Item for a Search Index.
I'm trying to create a search index to get all doucment (within the given document type aliases) where any of the fields (given in the comma separated string) contains the search terms. I'm doing this with the following code:
Once I have the List of ISearchResult items, I need to convert the list to a new object with the values froms the document. I've had a google round and noticed I should be able to use the following 'Fields' property within ISearchResult to get the values out:
List<MyObject> items = results.Select(r => new MyObject()
{
Title = r.Fields["title"]
});
But, Fields is empty in every ISearchResult item. So, I'm having to use the GetByID() method to grab each document first, which is making the page very slow to load.
Is there something I've missed to get these ISearchResult items with the Fields property populated?
Sorry for taking so long to respond. I've only just seen the message.
There is a Values property but it is always Null. But, I've noticed if I change the List<ISearchResults> results to an array, the Values property is populated. Do you have any idea why that would be?
Getting Field values within ISearchResult Item for a Search Index.
I'm trying to create a search index to get all doucment (within the given document type aliases) where any of the fields (given in the comma separated string) contains the search terms. I'm doing this with the following code:
Once I have the List of ISearchResult items, I need to convert the list to a new object with the values froms the document. I've had a google round and noticed I should be able to use the following 'Fields' property within ISearchResult to get the values out:
But, Fields is empty in every ISearchResult item. So, I'm having to use the GetByID() method to grab each document first, which is making the page very slow to load.
Is there something I've missed to get these ISearchResult items with the Fields property populated?
Hi Lewis
Looking at the Examine source:
https://github.com/Shazwazza/Examine/blob/release/1.2/src/Examine/SearchResult.cs#L42
Does a SearchResult entity have a Values property?
Which is a dictionary of results?
or perhaps even
as a short cut?
regards
marc
Hi Marc,
Sorry for taking so long to respond. I've only just seen the message.
There is a Values property but it is always Null. But, I've noticed if I change the
List<ISearchResults> results
to an array, the Values property is populated. Do you have any idea why that would be?Regards, Lewis
is working on a reply...