I am want to implement a pdf search using UmbracoExamine.Pdf, but I don't really know how to do it. I have used the class from this blog, but it doesn't work.
The documentation I found on examine pdf is for a multi index searcher, but I don't want that.
This is how my code looks like so far:
[HttpPost]
public ActionResult pdfSearch(string searchTerm)
{
var test = querySearchIndex(searchTerm);
return Json(test);
}
private ISearchResults querySearchIndex(string searchTerm)
{
if (ExamineManager.Instance.TryGetIndex("PDFIndex", out var index))
{
ISearcher searcher = index.GetSearcher();
IQuery query = searcher.CreateQuery(null, BooleanOperation.And);
string searchFields = "fileTextContent";
IBooleanOperation terms = query.GroupedOr(searchFields.Split(','), searchTerm);
return terms.Execute();
}
else
{
throw new InvalidOperationException($"No Index found with name PDFIndex");
}
}
I am assuming you have installed that package. So in the umbraco backoffice under settings examine dashboard do you see the pdf index and are you able to search for stuff in that index? Does it find your pdf?
This is what it looks like for my pdf index you can see I have 32 items
One thing to note is that the pdf indexer it uses itextsharp and that does not always extract pdf content.
In your code can you before doing terms.Execute() can you do searcher.ToString() or it may be terms.ToString() one of those will give you the generated lucene query I need to see that to get a handle on whats going.
Ok so the query itself looks fine to me. One more thing to try can u download https://code.google.com/archive/p/luke/downloads luke lukeall-3.5.0.jar you will need to have java installed on your machine. Then run that jar and open the index using it then in search tab paste
+(fileTextContent:protection)
Use standard analyser and see if you get any results.
UmbracoExamine.Pdf search implementation
Hi everyone
I am want to implement a pdf search using UmbracoExamine.Pdf, but I don't really know how to do it. I have used the class from this blog, but it doesn't work. The documentation I found on examine pdf is for a multi index searcher, but I don't want that. This is how my code looks like so far:
What am I doing wrong? Thanks
Raluca,
I am assuming you have installed that package. So in the umbraco backoffice under settings examine dashboard do you see the pdf index and are you able to search for stuff in that index? Does it find your pdf?
This is what it looks like for my pdf index you can see I have 32 items
One thing to note is that the pdf indexer it uses itextsharp and that does not always extract pdf content.
Hi Ismail
Yes I've installed the package, and my backoffice looks like yours. My search also returns results in there.
Raluca,
In your code can you before doing terms.Execute() can you do searcher.ToString() or it may be terms.ToString() one of those will give you the generated lucene query I need to see that to get a handle on whats going.
Regards
Ismail
Hi Ismail
searcher.ToString() comes up null, and terms.ToString() is:
'Protection' is my search term
Regards
Raluca,
Ok so the query itself looks fine to me. One more thing to try can u download https://code.google.com/archive/p/luke/downloads luke lukeall-3.5.0.jar you will need to have java installed on your machine. Then run that jar and open the index using it then in search tab paste
Use standard analyser and see if you get any results.
is working on a reply...