the first time I get in contact with the ExternalSearcher and I try to extend the query to exclude special documenttypes for my search results.
But I don't find the correct syntax to select the correct data. Here is the statement I want to adjust
var results = searcher.Search(criteria2)
.Where(x => (Here happens some magic I can't show to public)
.ToList();
So I search the correct wording to exclude some documenttypes. I've already thought about this solution, but the key in the dictionary seems to be wrong. How can I find out how to get the correct key?
var results = searcher.Search(criteria2)
.Where(x => (Here happens some magic I can't show to public)
&&(
x.Fields["DocumentTypeAlias"] != "infografikTeaser"
) )
.ToList();
Another try:
var results = searcher.Search(criteria2)
.Where(x => (Here happens some magic I can't show to public))
.Not().
.Field("DocumentTypeAlias","infografikTeaser").
.ToList();
My knowledge about ExternalSearcher is very limited, maybe you give me some hints or tutorials so I can understand the technique behind this querying.
Thank you very much for your fast reply. I'm sorry, but I'm not allowed to post the code, but I try to give you some parts:
var criteria = searcher.CreateSearchCriteria();
var query = new StringBuilder();
....(create query)....
var criteria2 = criteria.RawQuery(query.ToString());
query is a StringBuilder and there are many statements looking similiar to this
I didn't write the code, so I can't answer the question why we are using a raw query here :) I think you give me all information I need and I try to put it together. Thanks ;)
ExternalSearcher create Searchcriteria
Hi,
the first time I get in contact with the ExternalSearcher and I try to extend the query to exclude special documenttypes for my search results.
But I don't find the correct syntax to select the correct data. Here is the statement I want to adjust
So I search the correct wording to exclude some documenttypes. I've already thought about this solution, but the key in the dictionary seems to be wrong. How can I find out how to get the correct key?
Another try:
My knowledge about ExternalSearcher is very limited, maybe you give me some hints or tutorials so I can understand the technique behind this querying.
Thank you in advance for your input.
Cheers Nadine
Nadine,
You are using the searcher to search then trying to further filter the results using link which is not good. Can you show me the code for criteria2.
If you want to ignore certain document types from your search you would do something like:
var criteria = _searcher.CreateSearchCriteria(IndexTypes.Content);
var examineQuery = criteria.Field("searchablePath", query.SiteRootId.ToString());
examineQuery.Not().Field(HideFromNavigation, 1.ToString());
foreach (var nodeTypeAlias in query.NodeTypeAliases) { examineQuery.Not().Field("nodeTypeAlias", nodeTypeAlias); }
The ExternalSearcher is used to perform searches on your content using Examine which is a wrapper around lucene.net search engine.
More information on it can be found here https://our.umbraco.org/Documentation/Reference/Searching/Examine/
Thank you very much for your fast reply. I'm sorry, but I'm not allowed to post the code, but I try to give you some parts:
query is a StringBuilder and there are many statements looking similiar to this
I try to understand your code and the tutorial, thank you!
Nadine,
Any reason why you are using raw query? Either way you need to update raw query and add to it:
Also add more of these for any other node types you want to exclude.
You can also test your raw queries on your external index using luke. See https://code.google.com/archive/p/luke/downloads use v 3.5.0 you will need java installed on your machine. The index lives in \App_Data\TEMP\ExamineIndexes\External\Index if you dont want to use luke there is also package https://our.umbraco.org/projects/backoffice-extensions/cogworks-examine-inspector/ you can test raw queries there as well
Regards
Ismail
I didn't write the code, so I can't answer the question why we are using a raw query here :) I think you give me all information I need and I try to put it together. Thanks ;)
it is working with
You are great, thank you so much for your help!!
is working on a reply...