Tuesday, May 24, 2016

How to disable Full text search in ElasticSearch

Elastic search will index every field and every word within a value.

For Example:

Document 1 has : "text": "Hello World"

Document 2 has : "text": "Hello Srikanth"

ElasticSearch by default will create many indexes and in that the 3 index would be, ["Hello", "World", "Srikanth"]

In some case we want to disable the Full text search, So that we can aggregate by that value.

For Example:

Document 1 has : "filepath": "/home/srikanth/1.c"
Document 2 has : "filepath": "/home/srikanth/2.c"

By default, ElasticSearch will index these documents by ["home", "srikanth, ".c"] , So at the time of aggregating with the path, these values will mess up the aggregated document count.

So we have to tell ElasticSearch, not to index the data by

PUT indexName 
{ "mappings": { "type": { "properties": { "filepath": { "type": "string",
                     "index": "not_analyzed" } } } } }

(or) PUT indexName/_mapping/type
{ "properties": { "filepath": { "type": "string",
                     "index": "not_analyzed" } }

By this we tell ElasticSearch, that we will always search by the full string and not by sub-strings.

Monday, April 18, 2016

How to allocate memory for Node.js server

Sometimes while making heavy calculations it is possible that node.js runs out of memory and throws this error "FATAL ERROR- JS Allocation failed – process out of memory" 

By default node.js occupies 512MB RAM in a 32 bit machine and 1.4GB RAM in a 64bit machine
This is how we can increase it. 

Monday, March 9, 2015

How to make Grid text selectable in DHTMLX ?

Just adding this to Grid configuration worked!

  grid.entBox.onselectstart = function(){ return true; };

Reference : http://forum.dhtmlx.com/viewtopic.php?f=2&t=18963

Thursday, January 22, 2015

Thursday, June 26, 2014

Adding a pointer border to a div using CSS3

Adding a pointer border to a div using CSS3

Monday, February 4, 2013

Making Will Paginate Ajax + Rails 3

1. Create a helper file : app / helpers / remote_link_pagination_helper.rb

module RemoteLinkPaginationHelper
  class LinkRenderer < WillPaginate::ActionView::LinkRenderer
    def link(text, target, attributes = {})
      attributes['data-remote'] = true

2. In the View File where pagination links come, add this line. (@people is the array to paginate)

will_paginate @people, :renderer => 'RemoteLinkPaginationHelper::LinkRenderer'

Now the links must work with Ajax