Documentation
¶
Overview ¶
Package query defines a structured builder for search query strings.
Example ¶
package main
import (
"fmt"
"github.com/928799934/twitter/query"
)
func main() {
b := query.New()
q := b.And(
b.Or(
b.All("red", "green", "blue"),
b.Some("black", "white"),
),
b.HasImages(),
b.Not(b.IsRetweet()),
b.IsReply(),
)
fmt.Printf("Valid: %v\nQuery: %s\n", q.Valid(), q.String())
}
Output: Valid: true Query: ((red green blue) OR black OR white) has:images -is:retweet is:reply
Index ¶
- type Builder
- func (Builder) All(ss ...string) Query
- func (Builder) And(qs ...Query) Query
- func (Builder) Entity(s string) Query
- func (Builder) From(s string) Query
- func (Builder) HasHashtags() Query
- func (Builder) HasImages() Query
- func (Builder) HasLinks() Query
- func (Builder) HasMedia() Query
- func (Builder) HasMentions() Query
- func (Builder) HasVideos() Query
- func (Builder) Hashtag(s string) Query
- func (Builder) InThread(s string) Query
- func (Builder) IsReply() Query
- func (Builder) IsRetweet() Query
- func (Builder) IsVerified() Query
- func (Builder) Lang(s string) Query
- func (Builder) Mention(s string) Query
- func (Builder) Not(q Query) Query
- func (Builder) Or(qs ...Query) Query
- func (Builder) RetweetOf(s string) Query
- func (Builder) Some(ss ...string) Query
- func (Builder) To(s string) Query
- func (Builder) URL(s string) Query
- func (Builder) Word(s string) Query
- type Query
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct{}
A Builder exports methods to construct query terms. A zero value is ready for use.
func (Builder) HasHashtags ¶
HasHashtags matches tweets that contain at least one hashtag.
func (Builder) HasMentions ¶
HasMentions matches tweets that contain at least one mention.
func (Builder) HasVideos ¶
HasVideos matches tweets that contain "native" twitter videos. This does not include links to video on other sites.
func (Builder) IsVerified ¶
IsVerified matches tweets whose authors are verified.
func (Builder) Lang ¶
Lang matches tweets marked as being in the specified language. A tweet will have at most one language tag assigned.
type Query ¶
type Query interface {
// Query returns the query in string format.
String() string
// Valid reports whether the query is valid, meaning it contains at least
// one standalone query term. A valid query may contain invalid subqueries.
Valid() bool
}
A Query represents a query structure that can be rendered into a query string and checked for validity.