using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Examine;
namespace ExamineTest.usercontrols { public static class SearchResultExtensions { public static string FullUrl(this SearchResult sr) { return umbraco.library.NiceUrl(sr.Id); }
}
public partial class DemoSearchResults : System.Web.UI.UserControl { /// <summary> /// The term being searched on /// </summary> protected string SearchTerm { get; private set; }
/// <summary> /// The search results list /// </summary> protected IEnumerable<SearchResult> SearchResults { get; private set; }
public DemoSearchResults() { SearchTerm = string.Empty; SearchResults = new List<SearchResult>();
Sounds ok to me (from looking at the config settings), have you checked whether the fields get into the indexes? Can use Luke to open up the index files and check whether the fields can actually be found in the index
on ur search results page write out the generated query ( filter.ToString() in your case should give you the generated query) then try that query in luke try changing the analyser in luke to see if you get results for that query. Are you usng rc3 of examine?
Or is the output what you actually get when you do .ToString() on criteria object? If its the latter then you may need to put on codeplex as issue with your code as it may be a bug.
If you disable async on the indexer it will be able to write to the Umbraco log table if/ when errors occur during indexing. Try this as it may give a bit of an insight into any problems that are causing the fields not to be indexed.
Additionally, the fields are case-sensitive, so ensure that your field names what you've got in the config match the alias in Umbraco.
Looking at your config for store set index you have
Lucene.Net.Analysis.WhitespaceAnalyzer
Try using that analyser in luke and i reckon you will not get any results for same query. So for your store set indexer and searcher take out that analyser so you then have
It caught be out as well, but having done some lucene before knew a little about the analyzers. Two things are absolute must when working with lucene, Luke and the lucene in action book will save a lot time and effort.
Examine not giving UserFields in results
I have tried to follow the video's about the examine function in Umbraco, and the search is working and giving results.
The problem is that the results are only the built in fields and not the custom fields I have chosen.
What am I doing wrong/where is a good place to look?
Am happy to post any bits of code needed.
Many thanks.
Have you added those user fields to the config file for indexing?
<ExamineLuceneIndexSets>
<!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/ExamineIndexes/Internal/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName" />
<add Name="updateDate" />
<add Name="writerName" />
<add Name="path" />
<add Name="nodeTypeAlias" />
<add Name="parentID" />
</IndexAttributeFields>
<IndexUserFields />
<IncludeNodeTypes/>
<ExcludeNodeTypes />
</IndexSet>
</ExamineLuceneIndexSets>
Add your user fields under the IndexUserFields node. Or if you need to limit or exclude certain node types, use the corresponding node in the config.
Hope this helps.
Regards,
/Dirk
Dirk, thank you for your reply.
I have done this, the files I am using are:
ExamineIndex.config
ExamineSettings.config
ASCX
And finally code behind.
I am using Umbraco 4.5.1.
I hope this helps.
Sounds ok to me (from looking at the config settings), have you checked whether the fields get into the indexes? Can use Luke to open up the index files and check whether the fields can actually be found in the index
Let's know what you find!
Cheers,
/Dirk
Dirk
Thank you for your reply, it has taken a while to get Java installed on the server.
They are in the index.
I assume this means the ascx is wrong somewhere along the line?
Thanks
TT
on ur search results page write out the generated query ( filter.ToString() in your case should give you the generated query) then try that query in luke try changing the analyser in luke to see if you get results for that query. Are you usng rc3 of examine?
Regards
Ismail
Ismail
Thank you for your suggestion, I will give it a go.
I am using the version of Examine that came with Umbraco 4.5.1
Regards
TT
Ismail
Have tried the following, and am seeing this error:
Cannot parse '{SearchIndexType: Content, LuceneQuery: +(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content } ': Encountered " <RANGEEX_GOOP> "LuceneQuery: "" at line 1, column 27.
Was expecting:
"}" ...
Does this help?
Regards
TT
When say tried the following do you mean you pasted the following query into luke?
{SearchIndexType: Content, LuceneQuery: +(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content }
If so the that is not correct what you need to paste is
+(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content
Or is the output what you actually get when you do .ToString() on criteria object? If its the latter then you may need to put on codeplex as issue with your code as it may be a bug.
Regards
Ismail
If you disable async on the indexer it will be able to write to the Umbraco log table if/ when errors occur during indexing. Try this as it may give a bit of an insight into any problems that are causing the fields not to be indexed.
Additionally, the fields are case-sensitive, so ensure that your field names what you've got in the config match the alias in Umbraco.
Ismail
Thank you for your reply.
The top one, is what the .ToString() is producing, and I copied into Luke.
Have now tried the lower option and got a result in Luke.
slace, I will give this a go.
I will upgrade to 4.5.2 in a couple of minutes just to see if this helps.
Many thanks
TT
TT,
Looking at your config for store set index you have
Lucene.Net.Analysis.WhitespaceAnalyzer
Try using that analyser in luke and i reckon you will not get any results for same query. So for your store set indexer and searcher take out that analyser so you then have
Then rebuild your storeset index, when you dont specify analyser it defaults to standard, then try search you should then get results.
Regards
Isamil
Ismail
Thanks for the suggestion, will give it a go.
Regards
TT
Ismail
Many thanks, that did the trick.
It is working now and giving results.
Thanks once again.
TT
TT,
It caught be out as well, but having done some lucene before knew a little about the analyzers. Two things are absolute must when working with lucene, Luke and the lucene in action book will save a lot time and effort.
Regards
Ismail
Ismail
Thanks for this, I have just ordered the book.
Thanks once again.
Regards
TT
I've done a bit of an overview of analyzers on my website: http://www.aaron-powell.com/lucene-analyzer
That'll keep you appeased until the book arrives ;)
Many thanks slace.
I will have a look at this.
Regards
TT
is working on a reply...