Previous Next JavaScript must be enabled to correctly display this content

## Running the Examples in Secure Mode

Assuming you have deployed a secure Oracle NoSQL store and Elasticsearch cluster by executing the steps presented in Secure Elasticsearch using Sheild, Deploying and Configuring a Secure Oracle NoSQL Store, and Install the Full Text Search Public Certificate in Elasticsearch appendices, you can now execute the commands presented in this section to:

- Create and Populate a Table in the Secure Oracle NoSQL Store
- Register the Store with the Secure Elasticsearch Cluster and Create a Full Text Index
- Execute Secure Full Text Search Queries On Elasticsearch Indexed Data

Create and Populate a Table in the Secure Oracle NoSQL Store

Execute the program LoadJsonExample in secure mode. For example,

    java –classpath /opt/ondb/kv/lib/kvstore.jar:src es.table.LoadJsonExample
            –store mystore
            –host kvhost1
            –port 5000
            –file ~/examples/es/docs/senator-info.json
            -table exampleJsonTable
            -security /tmp/FTS-client.login

Register the Store with the Secure Elasticsearch Cluster and Create a Full Text Index

From a client node configured for secure access to the Oracle NoSQL store, start an Admin CLI for the store. For example, from the host named clhost1, start the CLI as the user named FTS created and provisioned as described in Deploying and Configuring a Secure Oracle NoSQL Store,

On clhost1

    java -jar /opt/ondb/kv/lib/kvcli.jar runadmin
            –host kvhost1
            -port 5000
            –store mystore
            –security /tmp/FTS-client.login

      Logged in admin as FTS

    kv-> plan register-es
            –clustername escluster
            –host eshost1
            –port 29100
            –secure true
            -wait

      Executed plan 25, waiting for completion...
      Plan 25 ended successfully

    kv-> execute 'CREATE FULLTEXT INDEX jsonTxtIndex ON
        exampleJsonTable (
          jsonField.current{"type":"boolean"},
          jsonField.party{"type":"string","analyzer":"standard"},
          jsonField.duties.committe{"type":"string"},
          jsonField.contrib{"type":"double"})';

      Statement completed successfully

    kv-> exit

Execute Secure Full Text Search Queries On Elasticsearch Indexed Data

From a client node configured for secure access to the Elasticsearch cluster such as the clhost1 node presented in Secure Elasticsearch using Sheild, execute queries like the following:

On clhost1

    curl –k -E /tmp/elasticsearch-eshost1.pem
            --key /tmp/elasticsearch-eshost1.pkey
            –X GET 'http://eshost1:29100/_cat/indices'

    curl –k -E /tmp/elasticsearch-eshost2.pem
            --key /tmp/elasticsearch-eshost2.pkey
            –X GET 'http://eshost2:29100/ondb.kvstore.examplejsontable.jsontxtindex/_mapping?pretty'

    curl –k -E /tmp/elasticsearch-eshost3.pem
            --key /tmp/elasticsearch-eshost3.pkey
            –X GET 'http://eshost3:29100/ondb.kvstore.examplejsontable.jsontxtindex/_search?pretty'

    curl –k -E /tmp/elasticsearch-eshost1.pem
            --key /tmp/elasticsearch-eshost1.pkey
            –X GET 'http://eshost1:29100/ondb.mystore.examplejsontable.jsontxtindex/_search?pretty'
            '-d {query":{"bool":{
                    "must":{"match":{"jsonCol.party":"Democrat"}},
                    "must":{"match":"jsonCol.current":"true"}},
                    "must":{"range":{"jsonField.contrib":{"gte":"1000000.00","lte":20000000.00"}}},
                    "must":"match":{"jsonField.duties.committe":"Judiciary Apropriations"}}}}}'

Note:

The queries above can be sent to any of the nodes in the Elasticsearch cluster (eshost1, eshost2, or eshost3). Just be sure to specify the public certificate and private key corresponding to the particular node to which you send the query.