Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gemma McCombe 4 posts 96 karma points
    Apr 07, 2022 @ 08:20
    Gemma McCombe
    0

    I've tried implementing a basic search into my site, however I'm getting an EOF error when running it. I'm passing in "eng" as my term with no spaces or special characters.

    code:

    if (!_examineManager.TryGetIndex(UmbracoIndexes.ExternalIndexName, out IIndex index))
                throw new InvalidOperationException($"No index found by name {UmbracoIndexes.ExternalIndexName}");
    
            var searcher = index.Searcher;
            var results = searcher.CreateQuery(IndexTypes.Content)
                .Field("nodeName", searchTerm.MultipleCharacterWildcard())
                .Execute();
    

    error:

     Lucene.Net.QueryParsers.Classic.ParseException
      HResult=0x80131500
      Message=Cannot parse '__IndexType:content': Encountered "<EOF>" at line 1, column 0.
    Was expecting one of:
        <NOT> ...
        "+" ...
        "-" ...
        <BAREOPER> ...
        "(" ...
        "*" ...
        <QUOTED> ...
        <TERM> ...
        <PREFIXTERM> ...
        <WILDTERM> ...
        <REGEXPTERM> ...
        "[" ...
        "{" ...
        <NUMBER> ...
        <TERM> ...
        "*" ...
    
      Source=Lucene.Net.QueryParser
      StackTrace:
       at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
       at Examine.Lucene.Search.LuceneSearchQueryBase.ParseRawQuery(String rawQuery)
       at Examine.Lucene.Search.LuceneSearchQueryBase.GetFieldInternalQuery(String fieldName, IExamineValue fieldValue, Boolean useQueryParser)
       at Examine.Lucene.Search.LuceneSearchQuery.Search(QueryOptions options)
       at Examine.Lucene.Search.LuceneSearchQuery.Execute(QueryOptions options)
       at Examine.Lucene.Search.LuceneBooleanOperation.Execute(QueryOptions options)
       at FatMedia.BlackburnCollege.Services.Search.SearchService.FatMedia.BlackburnCollege.Services.Search.ISearchService.SiteSearch(String searchTerm) in C:\Projects\BlackburnCollege\src\FatMedia.BlackburnCollege.Services\Search\SearchService.cs:line 29
       at FatMedia.BlackburnCollege.Web.Controllers.CourseApi.CourseApiController.Search(SearchRequestModel requestModel) in C:\Projects\BlackburnCollege\src\FatMedia.BlackburnCollege.Web\Controllers\CourseApi\CourseApiController.cs:line 25
       at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
    
      This exception was originally thrown at this call stack:
        [External Code]
    
    Inner Exception 1:
    ParseException: Encountered "<EOF>" at line 1, column 0.
    Was expecting one of:
        <NOT> ...
        "+" ...
        "-" ...
        <BAREOPER> ...
        "(" ...
        "*" ...
        <QUOTED> ...
        <TERM> ...
        <PREFIXTERM> ...
        <WILDTERM> ...
        <REGEXPTERM> ...
        "[" ...
        "{" ...
        <NUMBER> ...
        <TERM> ...
        "*" ...
    
  • Gemma McCombe 4 posts 96 karma points
    Apr 27, 2022 @ 08:51
    Gemma McCombe
    102

    We found a fix for this issue by update our code as below:

     var query = index.Searcher.CreateQuery().NativeQuery($"+__IndexType:{indexTypeString}").And();
    
Please Sign in or register to post replies

Write your reply to:

Draft