Saturday, March 31, 2018

Project Management Calculations


BAC :Budget at Completion
EAC: Estimate at Completion

PV: Planned Value
EV:  Earned Value
AC: Actual Cost
CV : Cost Variance
SV: Scheduled Variance

EV= BAC* % actual completed
PV=BAC * % planned /passed

CV= EV- AC
SV= EV- PV

Scheduled Performance Index, SPI=EV/PV

SPI <1 means project is behind the schedule

Cost Performance Index CPI = EV/AC

CPI>1  Project is under budget

CPI <1 Project is over budget

EAC = BAC/ CPI

TCPI To Complete Performance Index= (BAC-EV) / (BAC-AC)

TCPI w.r.t EAC TCPI= (BAC-BCWP)/(EAC- ACWP)

BCWP = Budgeted Cost Work Performed
ACWP = Actual Cost Work Performed

Sunday, March 25, 2018

Elastic Search : Querying Index

Alias name: employee

I . Aliases
  _cat/aliases
   get _alias/employee_index

II . Search records
  GET employee_alias/_search
{
   "query": {"match": {
     "location.zipcode: "11123"
   }}
}

 GET employee-primary-xyz/_search
{
   "query": {"match": {
     "location.zipcode: ""
   }}
}

III . Size boolean query
 GET employee/_search
{
    "size": 1000,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "department": "sales"
          }
        }
      ]
    }
  }
}

IV. Multiple criteria

3. Multiple criteria:

GET employee/_search
{
      "size" : 400,
   "queries": [{"match": {
     "department": "sales"
   }},{"match": {
     "location":"UK"
   }}]
}

4. Delete all records by match query
POST employee/_delete_by_query
{
  "query": {
    "match": {
     "location": "UK"
    }
  }
}

5. Range Query
GET _search
{
    "query": {
        "range" : {
            "age" : {
                "gte" : 10,
                "lte" : 20,
                "boost" : 2.0
            }
        }
    }

}

6.  Range Query for Date
GET _search
{
    "query": {
        "range" : {
            "date" : {
                "gte" : "now-1d/d",
                "lt" :  "now/d"
            }
        }
    }

}

7. Range query for Date with Format 

GET _search
{
    "query": {
        "range" : {
            "born" : {
                "gte": "01/01/2012",
                "lte": "2013",
                "format": "dd/MM/yyyy||yyyy"
            }
        }
    }

}

8. Remove all records from an index
POST EMPLOYEE_INDEX/_delete_by_query
{
  "query" : {
        "match_all" : {}
    }
}


9. Search for some data value
GET /bank/_search
{
  "query": { "match": { "account_number": 20 } }
}


10. Term Query

Term query
get employee/_search
{
  "query": {
    "term" : { "lastName" : "Dane" }
  }
}

12. Querying from multiple indexes
GET employee, department/_search {
}



13. Delete by criteria:
curl -X POST "ES_HOST/employee/_delete_by_query?wait_for_completion=false"  -H 'Content-Type: application/json' -d'
{
  "query": {
    "match": {
      "employeeId": "123456"
    }
  }
}'

Sunday, March 4, 2018

Elastic Search : Meta-Data/Indices

ES provides near real time search capabilities.

Shards: Number of pieces the data is going to be divided.

Replicas: This is a failover mechanism ES provides in case the primary goes off line or fails.

Data Type:Text Vs Keyword
Text: Use  type as 'Text' when it requires full-text and relevancy search in documents.


Keyword: This is required when searching is based on exact value.Many operation like filtering, sorting, aggregation requires exact value.


Alisases:
  • Switch transparently between one index and another on a running cluster
  • Group multiple indices (for example, last_three_months)
  • Create “views” on a subset of the documents in an index


Aliases gives the following:

Add/ Remove indices to aliases
POST /_aliases
{
    "actions" : [
        { "remove" : { "index" : "test1", "alias" : "employee" } },
        { "add" : { "index" : "test2", "alias" : "employee" } }
    ]

}


POST /_aliases
{
    "actions" : [
        { "add" : { "indices" : ["employee-primary", "employee-secondary"], "alias" : "employee" } }
    ]
}



Associating main and backup/old indexes/indices for a given context employee:
GET /sample-app-index-spec/metadata/employee


Create Index to metadata
PUT /sample-app-index-spec/emp-metadata/employee
{
"context":"employee",
"main" : "employee-version2",
"previous": "employee-version1"
}

Get mapping :
GET employee/_mapping

GET employee-primary/_mapping

Get all aliases: GET _aliases,  get _cat/aliases

Get all indices: GET _cat/indices
Dilete all indice: DELETE INDEX_NAME

Adding a new node element:
"mappings": {
  "employee": {
    "preferredLocations": {
      "properties": {
        "city": {
          "properties": {
            "value": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      },
      "currenltLocations": {
       
      }
    }

Note: depending upon properties type text/keyword/number query performance will vary.

#. To make element searchable it should available in the mapping document. so that it is getting indexed and query can be made as per the mapping. If the element is not going to be searchable the new element can be added without part of mapping