Search Options

Defaults
The Samepoint Social Media API defaults to the following conditions: Default Boolean Operator: OR

Default search field: content

Fields
The Samepoint Social Media API supports fielded data. When performing a search you can either specify a field, or use the default field ( content ). You can search any field by typing the field name followed by a colon ":" and then the term you are looking for.

q= Search Switches Available:
• title example: /q/title:President/
• content example: /q/content:President/
• date_added example: /q/date_added:[2011-01-01T00:00:00Z TO 2011-02-28T00:00:00Z]/
• refer_site example: /q/refer_site:blogspot.com/
• name ( of poster ) example: /q/name:mary/

As an example, let’s assume a Social Media API index contains two fields, title and content where content is the default field. If you want to find the document with a title containing "President" which contains the content "economy", you can enter: title:"President" AND content:"economy"

Example API Call:
http://apipoint.samepoint.com/api/appid/<YOUR APPID>/apikey/<YOUR APPKEY>/q/title:"President" AND content:"economy"/format/json

BEST Practice: URLENCODE the q var. Remeber booleans are all CAPS. notice AND in above example

Wildcard Searches

Social Media API supports single and multiple character wildcard searches within single terms (not within phrase queries).
• To perform a single character wildcard search use the "?" symbol.
• To perform a multiple character wildcard search use the "*" symbol.

The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "text" or "test" you can use the search:
• te?t

Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search: test*
You can also use the wildcard searches in the middle of a term. te*t
Note: You cannot use a * or ? symbol as the first character of a search.

Fuzzy Searches
Social Media API supports fuzzy searches based on the Levenshtein Distance, or Edit Distance algorithm. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "roam" use the fuzzy search: roam~ This search will find terms like foam and roams. Starting with Social Media V2 an additional (optional) parameter can specify the required similarity. The value is between 0 and 1, with a value closer to 1 only terms with a higher similarity will be matched. For example: roam~0.8 The default that is used if the parameter is not given is 0.5.

Proximity Searches
Social Media API supports finding words are a within a specific distance away. To do a proximity search use the tilde, "~", symbol at the end of a Phrase. For example to search for a "economy" and "President" within 10 words of each other in a document use the search: "President economy"~10

Range Searches
Range Queries allow one to match comments whose field(s) values are between the lower and upper bound specified by the Range Query. Range Queries can be inclusive or exclusive of the upper and lower bounds. Sorting is done lexicographically. date_added:[2011-01-01T00:00:00Z TO 2011-02-28:00:00:00Z] ( Notice Zulu time)

Example RANGE API Call:
http://apipoint.samepoint.com/api/appid/<YOUR APPID>/apikey/<YOUR APPKEY>/q/title:"President" AND content:"economy" AND date_added:[2011-01-01T00:00:00Z TO 2011-02-28T00:00:00Z]/format/json

This will find comments whose date_added field have values between Jan 1,2011 Midnight and Fed. 28, 2011 Midnight, inclusive. Note that Range Queries are not reserved for date fields. You could also use range queries with non-date fields: title:{President TO Economy} This will find all comments whose titles are between President and Economy, but not including President and Economy. Inclusive range queries are denoted by square brackets. Exclusive range queries are denoted by curly brackets.

Boosting a Term
Social Media API provides the relevance level of matching comments based on the terms found. To boost a term use the caret, "^", symbol with a boost factor (a number) at the end of the term you are searching. The higher the boost factor, the more relevant the term will be. Boosting allows you to control the relevance of a document by boosting its term. For example, if you are searching for President economy and you want the term "President" to be more relevant boost it using the ^ symbol along with the boost factor next to the term.

You would enter:
President^4 economy This will make comments with the term President appear more relevant.

You can also boost Phrase Terms as in the example: /q/"President economy"^4 "economy"/ By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2)

Boolean Operators
Boolean operators allow terms to be combined through logic operators. Social Media API supports AND, "+", OR, NOT and "-" as Boolean operators(Note: Boolean operators must be ALL CAPS). The AND operator is the default conjunction operator. This means that if there is no Boolean operator between two terms, the AND operator is used.

OR Operator
The OR operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets. The symbol || can be used in place of the word OR. To search for comments that contain either "President economy" or just "President" use the
/q/"President economy" President "President economy" OR President/

AND Operator
The AND operator matches comments where both terms exist anywhere in the text of a single document. This is equivalent to an intersection using sets. The symbol && can be used in place of the word AND. To search for comments that contain "President economy" and "Economy" use the
q/"President economy" AND "Economy"/

+ Operater
The "" or required operator requires that the term after the "" symbol exist somewhere in the field of a single document. To search for comments that must contain "President" and may contain "economy" use the query:

/q/+President economy
/

NOT Operator
The NOT operator excludes comments that contain the term after NOT. This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT. To searbe used with just one term. For example, thech for comments that contain "President economy" but not "Economy" use the query: /q/"President economy" NOT "Economy"/

Note: The NOT operator cannot following search will return no results: NOT "President economy"

- Operator
The "-" or prohibit operator excludes comments that contain the term after the "-" symbol. To search for comments that contain "President economy" but not "Economy" use the query: "President economy" -"Economy"

Grouping
Social Media API supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query. To search for either "President" or "economy" and "website" use the /q/(President OR economy) AND website/ This eliminates any confusion and makes sure you that website must exist and either term President or economy may exist.

Field Grouping
Social Media API supports using parentheses to group multiple clauses to a single field. To search for a title that contains both the word "return" and the phrase "social media" use the query: /q/title:(+return +"social media")/
Escaping Special Characters
Social Media APIsupports escaping special characters that are part of the query syntax. The current list special characters are + – && || ! ( ) { } [ ] ^ " ~ * ? : \ To escape these character use the \ before the character.

For example to search for (1+1):2 use the query: /q/\(1\+1\)\:2/