Spring Data MongoDB - Core

org.springframework.data.mongodb.core.index
Class Index

java.lang.Object
  extended by org.springframework.data.mongodb.core.index.Index
All Implemented Interfaces:
IndexDefinition
Direct Known Subclasses:
CompoundIndexDefinition

public class Index
extends Object
implements IndexDefinition

Author:
Oliver Gierke, Christoph Strobl

Nested Class Summary
static class Index.Duplicates
           
 
Constructor Summary
Index()
           
Index(String key, Order order)
          Deprecated. use #Index(String, Direction) instead.
Index(String key, Sort.Direction direction)
           
 
Method Summary
 Index background()
          Build the index in background (non blocking).
 Index expire(long value)
          Specifies TTL in seconds.
 Index expire(long value, TimeUnit unit)
          Specifies TTL with given TimeUnit.
 com.mongodb.DBObject getIndexKeys()
           
 com.mongodb.DBObject getIndexOptions()
           
 Index named(String name)
           
 Index on(String key, Order order)
          Deprecated. use #on(String, Direction) instead.
 Index on(String key, Sort.Direction direction)
           
 Index sparse()
          Skip over any document that is missing the indexed field.
 String toString()
           
 Index unique()
          Reject all documents that contain a duplicate value for the indexed field.
 Index unique(Index.Duplicates duplicates)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Index

public Index()

Index

public Index(String key,
             Sort.Direction direction)

Index

@Deprecated
public Index(String key,
                        Order order)
Deprecated. use #Index(String, Direction) instead.

Creates a new Indexed on the given key and Order.

Parameters:
key - must not be null or empty.
order - must not be null.
Method Detail

on

@Deprecated
public Index on(String key,
                           Order order)
Deprecated. use #on(String, Direction) instead.

Adds the given field to the index.

Parameters:
key - must not be null or empty.
order - must not be null.
Returns:

on

public Index on(String key,
                Sort.Direction direction)

named

public Index named(String name)

unique

public Index unique()
Reject all documents that contain a duplicate value for the indexed field.

Returns:
See Also:
http://docs.mongodb.org/manual/core/index-unique/

sparse

public Index sparse()
Skip over any document that is missing the indexed field.

Returns:
See Also:
http://docs.mongodb.org/manual/core/index-sparse/

background

public Index background()
Build the index in background (non blocking).

Returns:
Since:
1.5

expire

public Index expire(long value)
Specifies TTL in seconds.

Parameters:
value -
Returns:
Since:
1.5

expire

public Index expire(long value,
                    TimeUnit unit)
Specifies TTL with given TimeUnit.

Parameters:
value -
unit -
Returns:
Since:
1.5

unique

public Index unique(Index.Duplicates duplicates)
Parameters:
duplicates -
Returns:
See Also:
http://docs.mongodb.org/manual/core/index-creation/#index-creation-duplicate-dropping

getIndexKeys

public com.mongodb.DBObject getIndexKeys()
Specified by:
getIndexKeys in interface IndexDefinition

getIndexOptions

public com.mongodb.DBObject getIndexOptions()
Specified by:
getIndexOptions in interface IndexDefinition

toString

public String toString()
Overrides:
toString in class Object

Spring Data MongoDB - Core

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.