Flexible NoSQL hotness. With search.

4.4 Search API

  • http://api.thriftdb.com/{bucket}/{collection}/_search
    Description:
    Search across items in collection
    HTTP Methods:
    • GET - Execute a search across items in collection
      URL Arguments:
      Argument Datatype Default
      q string none
      start integer 0
      limit integer 10
      sortby string 'score desc'
      filter[fields][<fieldname>][] string none
      filter[queries][] string none
      facet[fields][<fieldname>][include] boolean false
      facet[fields][<fieldname>][exclude_filter] boolean true
      facet[fields][<fieldname>][start] integer 0
      facet[fields][<fieldname>][limit] integer 10
      facet[queries][] string none
      weights[<fieldname>] float 1.0
      boosts[fields][<fieldname>] float none
      boosts[filters][<filterstring>] float none
      boosts[functions][<functionstring>] float none
      highlight[markup_items] boolean false
      highlight[include_matches] boolean false

      • q
        Query string
      • start
        Ordinal position of first result. First position is 0. Maximum is 1000.
      • limit
        Number of results to return. Maximum is 100.
      • sortby
        Comma separated list of (fieldname/fieldorder) pairs to sort the results by (e.g. 'username asc, age desc'). Default is 'score desc'.
      • filter[fields][<fieldname>][]
        Attribute (fieldname/fieldvalue) pair to filter results on.
      • filter[queries][]
        Arbitrary filter query string
      • facet[fields][<fieldname>][include]
        If specified, perform faceting on given fieldname
      • facet[fields][<fieldname>][exclude_filter]
        Remove <fieldname> from filters when calculating facets for <fieldname>.
      • facet[fields][<fieldname>][start]
        Ordinal position of first facet to return. First position is 0. Maximum is 1000.
      • facet[fields][<fieldname>][limit]
        Number of facets to return. Default is 10. Maximum is 100.
      • facet[queries][]
        Arbitrary facet query string
      • weights[<fieldname>]
        In score calculation, use given weight value for each text match found in <fieldname>
      • boosts[fields][<fieldname>]
        In score calculation, use the boost factor times the value of <fieldname>
      • boosts[filters][<filterstring>]
        In score calculation, use the boost factor for each match that satisfies <filterstring>
      • boosts[functions][<functionstring>]
        In score calculation, use the boost factor times value of <functionstring>
      • highlight[markup_items]
        If specified, wrap matched terms in items with <strong> tags
      • highlight[include_matches]
        If specified, include match tokens
      Response Object:
      • hits - The total number of matched items
      • time - The amount of time it took to process the search request
      • request{} - The request parameters used by the server
        • q
        • start
        • limit
        • sortby
        • filter{}
          • fields{<fieldname>:<fieldvalues>[]}
          • queries[]
        • facet{}
          • fields{}
            • <fieldname>{}
              • include
              • start
              • limit
              • exclude_filter
          • queries[]
        • weights{<fieldname>:<weightvalue>}
        • boosts{}
          • fields{<fieldname>:<boostfactor>}
          • filters{<filterstring>:<boostfactor>}
          • functions{<functionstring>:<boostfactor>}
        • highlight{}
          • markup_items
          • include_matches
      • results[]{} - Sorted list of matched items and highlights
        • item{} - A matched item
        • score
      • facet_results{}
        • fields
          • <fieldname>{}
            • facets[]{}
              • value - The value of the facet
              • count - The number of matched items
        • queries{<queryvalue>:<querycount>}
      HTTP Responses:
      • 200 OK - Search result in response body
      Sample Requests/Responses:
      GET /test_bucket/cars/_search?q=porsche HTTP/1.1
      HOST: api.thriftdb.com
      Content-Type: application/json
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "hits"   : 2,
          "time"   : 0.020519,
          "request": {
      	"q"     : "porsche",
      	"start" : 0,
      	"limit" : 10,
              "sortby": "score desc",
      	"filter": {
      	    "fields" : {},
      	    "queries": []
      	},
      	"facet": {
      	    "fields" : {},
      	    "queries": []
      	},
      	"weights": {
      	    "make" : 1.0,
      	    "model": 1.0,
      	    "color": 1.0
      	},
      	"boosts": {
      	    "fields"   : {},
      	    "filters"  : {},
      	    "functions": {}
      	},
      	"highlight": {
      	    "markup_items"   : false,
      	    "include_matches": false
      	}
          },
          "results": [
              {
                  "item": {
                      "_id"  : "1", 
                      "color": "black", 
                      "make" : "Porsche", 
                      "model": "911", 
                      "year" : 1974
                  },
      	    "score": 1.0
              }, 
              {
                  "item": {
                      "_id"  : "2", 
                      "color": "red", 
                      "make" : "Porsche", 
                      "model": "911", 
                      "year" : 2007
                  },
      	    "score":1.0
              }
          ],
          "facet_results": {
      	"fields" : {},
      	"queries": {}
          }
      }
      
      GET /test_bucket/cars/_search?q=porsche&highlight[include_matches]=true
      HOST: api.thriftdb.com
      Content-Type: application/json
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "hits"   : 2,
          "time"   : 0.020519,
          "request": {
      	"q"     : "porsche",
      	"start" : 0,
      	"limit" : 10,
              "sortby": "score desc",
      	"filter": {
      	    "fields" : {},
      	    "queries": []
      	},
      	"facet": {
      	    "fields" : {},
      	    "queries": []
      	},
      	"weights": {
      	    "make" : 1.0,
      	    "model": 1.0,
      	    "color": 1.0
      	},
      	"boosts": {
      	    "fields"   : {},
      	    "filters"  : {},
      	    "functions": {}
      	},
      	"highlight": {
      	    "markup_items"   : false,
      	    "include_matches": true
      	}
          },
          "results"    : [
              {
                  "item": {
                      "_id"                : "1", 
                      "color"              : "black", 
      		"color@matches"      : [],
                      "make"               : "Porsche",
                      "make@matches"       : [
      		    {
      			"pos"      : 0,
      			"startchar": 0,
      			"endchar"  : 7
      		    }
      		],
                      "model"              : "911",
                      "model@matches"      : [],
                      "year"               : 1974,
      		"description"        : "Classic Porsche rescued from salvage\ "
                                             "condition. Coolest porsche on the \ "
      		                       "block.",
                      "description@matches": [
      		    {
                              "pos"      : 1,
      			"startchar": 8,
      			"endchar"  : 15
      		    },
      		    {
      			"pos"      : 7,
      			"startchar": 56,
      			"endchar"  : 63
      		    }
      		]
                  },
      	    "score": 3.0
              }, 
              {
                  "item": {
                      "_id"                : "2", 
                      "color"              : "red",
      		"color@matches"      : [],
                      "make"               : "Porsche", 
      		"make@matches"       : [
      		    {
      			"pos"      : 0,
      			"startchar": 0,
      			"endchar"  : 7
      		    }
      		],
                      "model"              : "911", 
      		"model@matches"      : [],
                      "year"               : 2007,
      		"description"        : null,
      		"description@matches": []
                  },
      	    "score": 1.0
              }
          ],
          "facet_results": {
      	"fields" : {},
      	"queries": {}
          }
      }
      
      Examples:
« Prev Next »