Author Archives: Raghavendar T S

Remove/Delete/Drop a Property Value from a List/Array – Gremlin Query

Remove/Delete/Drop a Property Value from a List/Array – Gremlin Query

Remove/Delete/Drop a Property Value from a List/Array – Gremlin Query

//Create Vertex
graph.addVertex(label, 'TEST_LABEL', 'id', '12345');

//Add value1, value2, value3 in the property 'test_property'
g.V().hasLabel('TEST_LABEL').has('id','12345').property('test_property', 'value1');
g.V().hasLabel('TEST_LABEL').has('id','12345').property('test_property', 'value2');
g.V().hasLabel('TEST_LABEL').has('id','12345').property('test_property', 'value3');

//Drop the value 'value2' alone from the property 'test_field'
 g.V().hasLabel('TEST_LABEL').has('id','12345')
.properties('test_property').hasValue('value2').drop();

Note that the property test_property is a multiple cardinality string data type.

Related Links

  1. Gremlin Query Language - Create Vertex/Node and Edge/Relationship
  2. Check If Vertex/Edge Exist - Gremlin Query - Titan
  3. Update Properties of Multiple Edges - Gremlin Query - Titan
  4. Update Properties of Multiple Vertices - Gremlin Query - Titan
  5. Create Vertex If Does Not Exist - Gremlin Query - Titan
  6. Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan
  7. Update Vertex If Exist - Gremlin Query - Titan
  8. Update Multiple Properties of Vertex - Gremlin Query - Titan
  9. Remove/Delete/Drop a Property Value from a List/Array – Gremlin Query
Read More...

Elasticsearch Geo-Shape Slow Indexing Performance – Solved

Elasticsearch Geo-Shape Slow Indexing Performance - Solved

Elasticsearch Geo-Shape Slow Indexing Performance – Solved

           We were using Hosted Elasticsearch 1.4.4 to index geo-shape data with the following field mapping.

{
    "geoShapeField": {
        "type": "geo_shape",
        "tree": "quadtree",
        "tree_levels": 26 //Or use precision: "1m",
        "distance_error_pct": 0.025 // Optional, 0.025 is default
    }
}

           Then we planned to move the cluster to AWS ES 6.2 and applied the same mapping except distance_error_pct. We noticed that indexing geo-shapes were very slow in AWS ES 6.2 due to a missing distance_error_pct configuration. In Elasticsearch 1.4.4, the distance_error_pct value is set to 0.025 by default. If we explicitly set the tree value, distance_error_pct  is set to 0 in Elasticsearch 6.2 by default.

           Set distance_error_pct  to 0 to gain maximum spatial precision with reduced indexing performance. The maximum value for distance_error_pct is 0.5. If you see any indexing issues after Elasticsearch upgrade for geo-shapes, set the distance_error_pct to 0.025 which is the default value in earlier versions of Elasticsearch.

References:
  1. https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-geo-shape-type.html
  2. https://www.elastic.co/guide/en/elasticsearch/reference/6.2/geo-shape.html
  3. https://github.com/elastic/elasticsearch/issues/25833
  4. https://github.com/elastic/elasticsearch/issues/22087
  5. https://github.com/elastic/elasticsearch/issues/16444
  6. http://elasticsearch-users.115913.n3.nabble.com/Geo-shape-questions-td4028334.html

 

Moto E/Moto G/Moto X – Bluetooth not working/switching on – Solved

Moto E Moto G Moto X - Bluetooth not working or switching on - Solved

Moto E/Moto G/Moto X – Bluetooth not working/switching on – Solved

           I personally own Moto G4 Plus and all of a sudden I was not able to enable Bluetooth. If I switch on, the switch button will be enabled and nothing happens. If I go back and navigate the to the Bluetooth screen again, the switch will be still disabled. So how to solve it??? Here are the simple steps which will reset the app preferences.

Steps:

  1. Go to Settings -> Apps
  2. In the top right corner, click the 3 dotted menu button
  3. Click Reset app preferences
  4. Enjoy !!!

Location – Latitude/Longitude (Lat/Lon) to Degrees Minutes Seconds (DMS) Conversion – JavaScript

Location - Latitude Longitude (LatLon) to Degrees Minutes Seconds (DMS) Conversion - JavaScript

Location – Latitude/Longitude (Lat/Lon) to Degrees Minutes Seconds (DMS) Conversion – JavaScript

Sample JavaScript Program:

function truncate(n) {
    return n > 0 ? Math.floor(n) : Math.ceil(n);
}

let getDMS = function (dd, longOrLat) {
    let hemisphere = /^[WE]|(?:lon)/i.test(longOrLat)
    ? dd < 0
      ? "W"
      : "E"
    : dd < 0
      ? "S"
      : "N";
    
    const absDD = Math.abs(dd);
    const degrees = truncate(absDD);
    const minutes = truncate((absDD - degrees) * 60);
    const seconds = ((absDD - degrees - minutes / 60) * Math.pow(60, 2)).toFixed(2);
    
    let dmsArray = [degrees, minutes, seconds, hemisphere];
    return `${dmsArray[0]}°${dmsArray[1]}'${dmsArray[2]}" ${dmsArray[3]}`;
}

let lat = 13.041107;
let lon = 80.233232;

let latDMS = getDMS(lat, 'lat'); 
let lonDMS = getDMS(lon, 'long');
console.log('latDMS: '+ latDMS);
console.log('lonDMS: '+ lonDMS);

Result:

latDMS: 13°2'27.99" N
lonDMS: 80°13'59.64" E

cannot change DocValues type from SORTED to SORTED_SET – DataStax Graph – Titan – Solr

cannot change DocValues type from SORTED to SORTED_SET – DataStax Graph – Titan – Solr

Are you facing these errors???

  1. cannot change docvalues type from sorted_set to sorted for field field_name
  2. cannot change docvalues type from sorted to sorted_set for field field_name

No worries. We have the solution. First of all we need to know what DocValues means in Solr. You will find a lot of information in the internet. Now we will see why we are getting the error “cannot change DocValues type from SORTED_SET to SORTED for field field_name”.

Lets us consider we have a field named description with type solr.TextField with docValues property true. We will now have a separate data stored which is meant for performing efficient faceting, sorting and other operations. In order to support search requirements, we want to change the type to some other existing Solr supported types or even custom type. So basically we will update the vertex label schema and reindex the data. In this process, Solr will try to reindex the data with new schema changes. What If the field data values of the older field type is not compatible with the newer field type? Yes we get error in this case. So what is the solution? 

Solution:

  1. Update the field data type and disable DocValues
  2. Reindex Data
  3. Enable DocValue
  4. Reindex Data
  5. That’s it

Steps:

Step 1:

Execute the following queries in the server.

dsetool get_core_config {{GRAPH_NAME}}.{{VERTEX_LABEL}}_p > {{VERTEX_LABEL}}_config.xml

dsetool get_core_schema {{GRAPH_NAME}}.{{VERTEX_LABEL}}_p > {{VERTEX_LABEL}}_schema.xml

E.g.

dsetool get_core_config TESTGRAPH.TESTLABEL_p > TESTLABEL_config.xml

dsetool get_core_schema TESTGRAPH.TESTLABEL_p > TESTLABEL_schema.xml

The above two queries will create a config file and a schema file for the given vertex label. Take backup of the config and schema file.

Step 2:

Open the schema file TESTLABEL_schema.xml. You will find some similar to the following line.

<field docValues="true" indexed="true" multiValued="false"
name="description" stored="true" type="StrField"/>

Update the docValues property to false and save the file. Make sure you update the field data type which you want to change which is description in our case.

Step 3:

Execute the following command which will clear the existing docValues data.

dsetool reload_core TESTGRAPH.TESTLABEL_p reindex=true
schema=TESTLABEL_schema.xml solrconfig=TESTLABEL_config.xml

Step 4:

Open the schema file TESTLABEL_schema.xml. Update the docValues property to true and save the file.

Step 5:

Execute the following command which will create the required docValues data.

dsetool reload_core TESTGRAPH.TESTLABEL_p reindex=true
schema=TESTLABEL_schema.xml solrconfig=TESTLABEL_config.xml

Step 6:

Enjoy!!!