Unable to get gte and lte from elastic Java API in range query

I tried the following example based on what you wrote. That's the typical script which could help. So please, next time, provide such a script. It's easy to read and understand what you are doing.

DELETE test 
PUT test
{
  "mappings": {
    "properties": {
      "ipFromLong": {
        "type": "long"
      },
      "ipToLong": {
        "type": "long"
      }
    }
  }
}
POST test/_doc
{
  "ipToLong": 28147177550,
  "ipFromLong": 28147177543
}

From that example, we can test your subqueries:

GET test/_search
{
  "query": {
    "range": {
      "ipToLong": {
        "to": 28147177551
      }
    }
  }
}

This one gives the hit. Why this? Because for ipToLong: 28147177550 < 28147177551

But:

GET test/_search
{
  "query": {
    "range": {
      "ipFromLong": {
        "from": 28147177551
      }
    }
  }
}

This one gives no hit. Why this? Because for ipFromLong 28147177543 < 28147177551. So it can't match.

That's why your query can not match anything.

I'm now trying to understand what exactly you want to do actually.
And I wonder if you are trying to find values in intervals. In which case, I'd highly recommend using: