VectorDistanceFunction (Solr 3.6.2 API)
Keywords: org.apache.solr.search.function.distance.VectorDistanceFunction class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.search.function.distance
Class VectorDistanceFunction

    java.lang.Object
      org.apache.solr.search.function.ValueSource
          org.apache.solr.search.function.distance.VectorDistanceFunction

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  SquaredEuclideanFunction

    public class VectorDistanceFunction

extends ValueSource

Calculate the p-norm for a Vector. See http://en.wikipedia.org/wiki/Lp_space

Common cases:

- 0 = Sparseness calculation
- 1 = Manhattan distance
- 2 = Euclidean distance
- Integer.MAX_VALUE = infinite norm

See Also:
  `for the special case`, Serialized Form

Field Summary
`protected float` | `oneOverPower`
`protected float` | `power`
`protected MultiValueSource` | `source1`
`protected MultiValueSource` | `source2`

Constructor Summary
`VectorDistanceFunction(float power, MultiValueSource source1, MultiValueSource source2)`

Method Summary
`void` | `createWeight(Map context, Searcher searcher)` Implementations should propagate createWeight to sub-ValueSources which can optionally store weight info in the context.
`String` | `description()` description of field, used in explain()
`protected double` | `distance(int doc, DocValues dv1, DocValues dv2)` Calculate the distance
`boolean` | `equals(Object o)`
`DocValues` | `getValues(Map context, IndexReader reader)` Gets the values for this reader and the context that was previously passed to createWeight()
`int` | `hashCode()`
`protected String` | `name()`

Methods inherited from class org.apache.solr.search.function.ValueSource
`getSortField, getValues, newContext, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### source1

    protected MultiValueSource source1

### source2

    protected MultiValueSource source2

### power

    protected float power

### oneOverPower

    protected float oneOverPower

Constructor Detail

### VectorDistanceFunction

    public VectorDistanceFunction(float power,
                                  MultiValueSource source1,
                                  MultiValueSource source2)

Method Detail

### name

    protected String name()

### distance

    protected double distance(int doc,
                              DocValues dv1,
                              DocValues dv2)

  Calculate the distance

  Parameters:
    `doc` - The current doc
    `dv1` - The values from the first MultiValueSource
    `dv2` - The values from the second MultiValueSource
  Returns:
    The distance

### getValues

    public DocValues getValues(Map context,
                               IndexReader reader)
                        throws IOException

  Description copied from class: `ValueSource`
  Gets the values for this reader and the context that was previously passed to createWeight()

  Overrides:
    `getValues` in class `ValueSource`
  Throws:
    `IOException`

### createWeight

    public void createWeight(Map context,
                             Searcher searcher)
                      throws IOException

  Description copied from class: `ValueSource`
  Implementations should propagate createWeight to sub-ValueSources which can optionally store weight info in the context. The context object will be passed to getValues() where this info can be retrieved.

  Overrides:
    `createWeight` in class `ValueSource`
  Throws:
    `IOException`

### equals

    public boolean equals(Object o)

  Specified by:
    `equals` in class `ValueSource`

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in class `ValueSource`

### description

    public String description()

  Description copied from class: `ValueSource`
  description of field, used in explain()

  Specified by:
    `description` in class `ValueSource`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD