Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Connecting Unity to Elasticsearch

Discussion in 'General Discussion' started by nikolahristov98, Aug 2, 2018.

  1. nikolahristov98

    nikolahristov98

    Joined:
    Jun 15, 2018
    Posts:
    5
    Hey everybody,
    I'm new to Unity and currently working on a VR project that will load information(text and images) through Elasticsearch, however I'm having trouble integrating it. After a lot of effort and research I managed to install the NEST client alongside Elasticsearch.net(needed for NEST) through Visual Studio's Package Manager. I tested basic indexing functions on a separate project (not associated with Unity) to see if it works and it does. However the problem comes when I try to integrate it into my Unity project. I'm using the standard 'using Nest;' and Visual Studio is not giving me any errors, however Unity gives me a compile error: "The type or namespace name `Nest' could not be found. Are you missing an assembly reference?". I'm not sure how to tackle this. I tried standard solutions of this problem like "Reimport All" or deleting some folder but nothing seems to work. Does anybody know what the problem might be? Is it possible the client is simply not compatible for use in Unity? If so, is there a way to send a requests to Elasticsearch through Unity in some other way? All help is appreciated.

    Note: I did change the Scripting Runtime Version to ".NET 4.x Equivalent" since NEST was not compatible with .NET 3.5 and I had problem installing it in Visual Studio.

    Note2: In my "Packages" folder there are "NEST.6.2.0" and "Elasticsearch.Net.6.2.0" so the files do exist in there.

    Edit: I think I posted in the wrong subforum. I can't delete this. Sorry!
     
    Last edited: Aug 2, 2018
    Gotama likes this.
  2. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    226
    Unity does not support the nuget package manager, so adding packages through VS will not work.
    You have to download the package (and its dependencies) from nuget.org (download link is on the right side).
    Rename from *.nupkg to *.zip and open it, copy the .dlls from lib/net46 to your project's asset folder.
    Don't forget the dependencies. In this case it's the Elasticsearch.NET package.

    I have not tested these packages in particular but in general this should work.
     
    Gotama, Kiwasi and nikolahristov98 like this.
  3. nikolahristov98

    nikolahristov98

    Joined:
    Jun 15, 2018
    Posts:
    5
    It worked! Thank you so much!! I have been stuck on this for 2 whole days. You've saved me so much time. Thank you!
     
  4. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    226
    Glad I could help :)