简体   繁体   中英

Apache Ignite query / index

I have a particular question about indexing with Apache Ignite.

My need is to query the Cache without "knowing" the schema. Because I have no java class definition at some moments, so no annotation available. But Apache Ignite seems to need annotation to recognize fields.

Is there a way to define queryable fields at runtime?

I ask it because I'm building an technology agnostic application and I plug specialized class at runtime. Another problem for me is to extend classes for Apache Ignite and define fake fields just to make "the field" (assuming it's not the original field...) viewable from Apache Ignite.

Did someone had the same "problem"?

Original class Command :

public class Command {
    private String commandName;

    public void setCommandName(String commandName) {
        this.commandName = commandName;
    }
    public String getCommandName(){
        return this.commandName;
    }
}

Extended Command class for Ignite SQL uses :

public class IgniteCommand extends Command{
    @QuerySqlField (name="name", index = true)
    private String _commandName;

    @Override
    public void setCommandName(String commandName) {
        super.setCommandName(commandName);
        this._commandName = getCommandName();
    }
}

This above code works fine for me.

You can configure query entities at runtime but before cache started. See Spring XML configuration example in docs [1]. You can do the same programmatically.

You also can create indexes dynamically using DDL. See [2].

[1] https://apacheignite.readme.io/docs/indexes#queryentity-based-configuration [2] https://apacheignite.readme.io/docs/distributed-ddl#section-create-index

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM