0

I am currently implementing a RESTful API for Elastic Search. Is there a way to query ES with a generic value? For example, this will allow the user to pass in any key and value and this would convert the value to whatever typeof field it is. I feel like I am complicating it. Is there a simpler way to query ES with generic values being passed to it?

Ex:

I could pass the following: POST command -

RulesGreaterThanDictionary is :

  public Dictionary<string, Object> RulesGreaterThanDictionary { get; set; }

And the POST call is :

  {
        "RuleEquals":
        {
          "RulesEqualDictionary":
          {
            "email" : "ggg@gmail.com",
            "validUser" : true
          }
        },
          "RuleGreaterThan" : 
        {
            "RulesGreaterThanDictionary" : 
            {
              "minamount" : 10
            }
        }
    }

As this would query ES to find documents that have email equal to some email, and is a valid user as well as the minamount of the item is at least 10.

Something generic like that.

Has this already been implemented before? Thank you!

API_Base
  • 9
  • 5

1 Answers1

0

Another possibility is to write a wrapper

public class ValueWrapper {
    ... 
    public static final String VALUE = "value";

    private T value;

    // getter & setter
}

and than map the wrapper instead of you object which can be gerneric :)

Guillaume Fache
  • 813
  • 10
  • 21
marco
  • 1