martin-magakian / Amazing-Cloud-Search

Allow you to search, faceted search, add, update, remove objects from your Amazon Cloud Search Index in C#.
30 stars 17 forks source link

Runtime error while searching: RemoveHit not accessible due to its protection level #10

Closed gkbn closed 10 years ago

gkbn commented 10 years ago

Hi everyone!

I have been able to add documents successfully but search is giving me a strange issue inside CloudSearch.cs = > The runtime is unable to call dynamic RemoveHit(dynamic jsonDynamic) inside public virtual SearchResult SearchWithException(SearchQuery query).

An exception occurs with the following message: [Microsoft.CSharp.RuntimeBinder.RuntimeBinderException] = {"'AmazingCloudSearch.CloudSearch.RemoveHit(object)' is inaccessible due to its protection level"}

Here is the stack trace: StackTrace = " at CallSite.Target(Closure , CallSite , CloudSearch1 , Object )\r\n at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)\r\n at AmazingCloudSearch.CloudSearch1.SearchWithException(SearchQuery`1 query) in...

I am using .Net 4.5.

Can someone please help me with your thoughts/suggestions? I do understand that many people are already using this library, so I must be missing something here. Please advise.

Thanks in advance! Girish

martin-magakian commented 10 years ago

Hi,

That's a very strange error. Can you post the object your trying to save/search into CloudSearch?

Also, are you 100% sure your new entry is save into the database? Did you check from the CloudSearch console?

I think you should debug the function CloudSearch.PerformDocumentAction(...) and check the json return. Line 257: jsonResult.json

gkbn commented 10 years ago

Thank you so much for your quick response, Martin.

Yes, my new entry was saved into cloud search domain. I am able to search and find the documents using AWS console. Even the search API works as I am getting result back inside SearchWithException(). The exception occurs at RemoveHit() only after the json result comes back with matching document.

Here is the result json (value of jsonResult.json) at Line 209: "{\"rank\":\"-text_relevance\",\"match-expr\":\"(and id0:'salesorder' id1:'0' id2:'finance' id3:'alpharetta' id4:'1.1')\",\"hits\":{\"found\":2,\"start\":0,\"hit\":[{\"id\":\"ff1d761e_9226_4b74_bdcb_72fd807cabe0\",\"data\":{\"adjacencylist\":[],\"followed\":[\"NotFollowed\"],\"guid\":[\"ff1d761e-9226-4b74-bdcb-72fd807cabe0\"],\"id0\":[\"SalesOrder\"],\"id1\":[\"0\"],\"id2\":[\"Finance\"],\"id3\":[\"Alpharetta\"],\"id4\":[\"1.1\"],\"lastseen\":[\"0\"],\"logicalid\":[],\"name\":[\"4WtoJKi5}ts%<[s6=E]nT5zPn]hyf4U,7M@$[XkG=*M&+!f[xk2x3iE~\D kboMh?gln;nZdY6QIfsDlv, y\"\xL(@G7W~cL[dfC\"],\"nountype\":[],\"status\":[\"Open\"],\"type\":[\"D1F\_A%b,Bn@~nCs )7!\"],\"variationid\":[\"500\"]}}]},\"info\":{\"rid\":\"4671fc5dce83dc630e4285d4b0a3e5b2e3b49675e5ac4cb21baea23fe3a724dd4452deef30721f2a\",\"time-ms\":5,\"cpu-time-ms\":0}}"

After calling JsonConvert.DeserializeObject(jsonResult.json) on Line 214, the value of jsonDynamic is shown below:

Here is a document - search result from AWS Console:

  1. ff1d761e_9226_4b74_bdcb_72fd807cabe0 text_relevance: 148 adjacencylist:
    followed: NotFollowed guid: ff1d761e-9226-4b74-bdcb-72fd807cabe0 id0: SalesOrder id1: 0 id2: Finance id3: Alpharetta id4: 1.1 lastseen: 0 logicalid:
    name: 4WtoJKi5}ts%<[s6=E]nT5zPn]hyf4U,7M@$[XkG=*M&+!f[xk2x3iE~\D kboMh?gln;nZdY6QIfsDlv, y"\xL(@G7W~cL[dfC nountype:
    status: Open type: D1F_A%b,Bn@~nCs )7! variationid: 500

This is test data generated randomly hence the name and type are having all kinds of alphanumeric characters.

martin-magakian commented 10 years ago

Hummm... What if you try without the "name" field with those generated characters? Does it work.

DovetailSoftware team folked the project and worked on some issus about character encoding. https://github.com/DovetailSoftware/Amazing-Cloud-Search/

@GaryLCoxJr, @bbehrens do you guys understand this error?

gkbn commented 10 years ago

Thanks Martin! While waiting for your response, I tried exactly that by putting in some simple hard coded name and type. I am still getting the same exception.

One more thing, Martin. I had also tried moving the code from RemoveHit() method to SearchWithException(). That worked without any issues, but then I got the same exception at Line 230: _hitFeeder.Feed(searchResult, hit);

It seems like some issue of accessing "hit" ? Some access restriction between NewtonSoft and AmazingCloudSearch DLLs ?

martin-magakian commented 10 years ago

I read something about a bug in C# CLI on steak overflow.

It's probably no the problem but as I don't have any other idea it maybe worth updating to C# 5.0 At least to test and know if the error come from the C# CLI...

Sorry I can't help more

gkbn commented 10 years ago

Thanks for trying to help, Martin. It was really nice to see those quick responses from you. Will try .Net 4.5.1 and see if it helps. I am already on C# 5.0/.Net 4.5/VS2012. Will update if I find a solution.

martin-magakian commented 10 years ago

A very wired problem.

Please reopen this issu if it append again.