기타 index

mongoDB, redis 2015. 11. 9. 17:47

mongoDB의 index는 메모리상의 working Set 에  Cache되어 관리된다.

working Set에는 index외에도, 데이타 일부가 cache되지만,   index가 우선 cache되어 성능향상을 시키는 구조이다.

 

 

데이타가: type: "restratunt"

loc: [ 37, 132 ] 일 경우,  

 

<2D index>

 

 

db.data..ensureIndex( {loc:'2d', type:1} )

 => $near 나  $maxDistance 가 사용가능하다. 

 

 

 

<2dsphere index>

 

db.data..ensureIndex( {loc:'2dsphere', type:1} )

=> $near 나 $maxDistance 가 사용가능하다.  $gemetry를 사용할 수 있다.

db.data.find( {loc: {  $near: {   $geomerty: { type: "restaurant",  coordinates:[38,127] },  $maxDistance:2000 }   }})

 

 

<text search index>

 

db.data..ensureIndex( {type:'text'} )

db.data.find( {'$text:{$search:'restaurant'}'} )          //$text앞에 '는 빼도 될듯.

 

 

Posted by yongary
,