How to tag an object using the Java API?

Let’s say I want to add a single object to an index. I can use the following Java code:

Item item = …
index.addObject(item.getId(), item);

I would like item to be tagged with a specific value so that I can later restrict results in my multi-tenant web app by client id.

I can see in your docs I’m supposed to add tags. The examples are in JavaScript and JSON. I can see it is something like this:
_tags: [‘clientid_17’]

So to achieve this in Java, should I have a method called “get_tags()”? Or is there something built into the Java API to add tags at the time of adding an object to the index?

You should add the tags on the object creation, in the _tags property of your object.
In ruby, I do it like this:

  objectID: 'user_id',
  user_id: 'user_id'
  description: 'foo',
  _tag: 'user' + 'user_id'

I never did it in Java, but by looking in the documentation it should be something like this:

  new Client().setObjectID("myID1").setFirstName("Jimmie").setTag("clientid_myID1")

Hope I was able to help.