func (search *Search) PostQuery(query *SearchQuery) (SearchResp, error) {
	endpoint := fmt.Sprintf("%s/PostQuery", search.endpoint)
	client := NewHTTPClient(search.client)
	request := map[string]interface{}{}
	queryBytes, _ := json.Marshal(query)
	_ = json.Unmarshal(queryBytes, &request)
	request["__metadata"] = map[string]interface{}{"type": "Microsoft.Office.Server.Search.REST.SearchRequest"}
	for key, val := range request {
		if val == nil {
			delete(request, key)
		} else {
			switch kind := reflect.TypeOf(val).Kind().String(); kind {
			case "slice":
				request[key] = map[string]interface{}{
					"results": val,
				}
			case "int":
				if val.(int) == 0 {
					delete(request, key)
				}
			case "float64":
				if val.(float64) == 0 {
					delete(request, key)
				}
			case "string":
				if val.(string) == "" {
					delete(request, key)
				}
			default:
			}
		}
	}
	req, _ := json.Marshal(request)
	JSONReq := fmt.Sprintf("%s", req)
	body := []byte(TrimMultiline(`{ "request": ` + JSONReq + `}`))
	headers := map[string]string{
		"Accept":       "application/json",
		"Content-Type": "application/json;odata=verbose;charset=utf-8",
	}
	return client.Post(endpoint, bytes.NewBuffer(body), patchConfigHeaders(search.config, headers))
}
PostQuery gets search results based on a `query`
package api
import (
	"bytes"
	"encoding/json"
	"fmt"
	"reflect"
	"github.com/koltyakov/gosip"
)
type Search struct {
	client    *gosip.SPClient
	config    *RequestConfig
	endpoint  string
	modifiers *ODataMods
}
type SearchResp []byte
type SearchQuery struct {
	QueryText                             string                  `json:"Querytext"`                              
	QueryTemplate                         string                  `json:"QueryTemplate"`                          
	EnableInterleaving                    bool                    `json:"EnableInterleaving"`                     
	EnableStemming                        bool                    `json:"EnableStemming"`                         
	TrimDuplicates                        bool                    `json:"TrimDuplicates"`                         
	EnableNicknames                       bool                    `json:"EnableNicknames"`                        
	EnableFQL                             bool                    `json:"EnableFQL"`                              
	EnablePhonetic                        bool                    `json:"EnablePhonetic"`                         
	BypassResultTypes                     bool                    `json:"BypassResultTypes"`                      
	ProcessBestBets                       bool                    `json:"ProcessBestBets"`                        
	EnableQueryRules                      bool                    `json:"EnableQueryRules"`                       
	EnableSorting                         bool                    `json:"EnableSorting"`                          
	GenerateBlockRankLog                  bool                    `json:"GenerateBlockRankLog"`                   
	SourceID                              string                  `json:"SourceId"`                               
	RankingModelID                        string                  `json:"RankingModelId"`                         
	StartRow                              int                     `json:"StartRow"`                               
	RowLimit                              int                     `json:"RowLimit"`                               
	RowsPerPage                           int                     `json:"RowsPerPage"`                            
	SelectProperties                      []string                `json:"SelectProperties"`                       
	Culture                               int                     `json:"Culture"`                                
	RefinementFilters                     []string                `json:"RefinementFilters"`                      
	Refiners                              string                  `json:"Refiners"`                               
	HiddenConstraints                     string                  `json:"HiddenConstraints"`                      
	Timeout                               int                     `json:"Timeout"`                                
	HitHighlightedProperties              []string                `json:"HitHighlightedProperties"`               
	ClientType                            string                  `json:"ClientType"`                             
	PersonalizationData                   string                  `json:"PersonalizationData"`                    
	ResultsURL                            string                  `json:"ResultsUrl"`                             
	QueryTag                              string                  `json:"QueryTag"`                               
	ProcessPersonalFavorites              bool                    `json:"ProcessPersonalFavorites"`               
	QueryTemplatePropertiesURL            string                  `json:"QueryTemplatePropertiesUrl"`             
	HitHighlightedMultivaluePropertyLimit int                     `json:"HitHighlightedMultivaluePropertyLimit"`  
	EnableOrderingHitHighlightedProperty  bool                    `json:"EnableOrderingHitHighlightedProperty"`   
	CollapseSpecification                 string                  `json:"CollapseSpecification"`                  
	UIlanguage                            int                     `json:"UIlanguage"`                             
	DesiredSnippetLength                  int                     `json:"DesiredSnippetLength"`                   
	MaxSnippetLength                      int                     `json:"MaxSnippetLength"`                       
	SummaryLength                         int                     `json:"SummaryLength"`                          
	SortList                              []*SearchSort           `json:"SortList"`                               
	Properties                            []*SearchProperty       `json:"Properties"`                             
	ReorderingRules                       []*SearchReorderingRule `json:"ReorderingRules"`                        
}
type SearchSort struct {
	Property  string `json:"Property"`
	Direction int    `json:"Direction"`  
}
type SearchProperty struct {
	Name  string              `json:"Name"`
	Value SearchPropertyValue `json:"Value"`
}
type SearchPropertyValue struct {
	StrVal                      string   `json:"StrVal"`
	BoolVal                     bool     `json:"BoolVal"`
	IntVal                      int      `json:"IntVal"`
	StrArray                    []string `json:"StrArray"`
	QueryPropertyValueTypeIndex int      `json:"QueryPropertyValueTypeIndex"`  
}
type SearchReorderingRule struct {
	MatchValue string `json:"MatchValue"`
	Boost      int    `json:"Boost"`
	MatchType  int    `json:"MatchType"`  
}
type SearchResults struct {
	ElapsedTime           int                      `json:"ElapsedTime"`
	PrimaryQueryResult    *ResultTableCollection   `json:"PrimaryQueryResult"`
	Properties            []*TypedKeyValue         `json:"Properties"`
	SecondaryQueryResults []*ResultTableCollection `json:"SecondaryQueryResults"`
	SpellingSuggestion    string                   `json:"SpellingSuggestion"`
	TriggeredRules        []interface{}            `json:"TriggeredRules"`
}
type ResultTableCollection struct {
	QueryErrors        map[string]interface{} `json:"QueryErrors"`
	QueryID            string                 `json:"QueryId"`
	QueryRuleID        string                 `json:"QueryRuleId"`
	CustomResults      *ResultTable           `json:"CustomResults"`
	RefinementResults  *ResultTable           `json:"RefinementResults"`
	RelevantResults    *ResultTable           `json:"RelevantResults"`
	SpecialTermResults *ResultTable           `json:"SpecialTermResults"`
}
type ResultTable struct {
	GroupTemplateID              string           `json:"GroupTemplateId"`
	ItemTemplateID               string           `json:"ItemTemplateId"`
	ResultTitle                  string           `json:"ResultTitle"`
	ResultTitleURL               string           `json:"ResultTitleUrl"`
	RowCount                     int              `json:"RowCount"`
	TableType                    string           `json:"TableType"`
	TotalRows                    int              `json:"TotalRows"`
	TotalRowsIncludingDuplicates int              `json:"TotalRowsIncludingDuplicates"`
	Properties                   []*TypedKeyValue `json:"Properties"`
	Table                        *struct {
		Rows []*struct {
			Cells []*TypedKeyValue `json:"Cells"`
		} `json:"Rows"`
	} `json:"Table"`
	Refiners []*struct {
		Name    string `json:"Name"`
		Entries []*struct {
			RefinementCount string `json:"RefinementCount"`
			RefinementName  string `json:"RefinementName"`
			RefinementToken string `json:"RefinementToken"`
			RefinementValue string `json:"RefinementValue"`
		} `json:"Entries"`
	} `json:"Refiners"`
}
func NewSearch(client *gosip.SPClient, endpoint string, config *RequestConfig) *Search {
	return &Search{
		client:    client,
		endpoint:  endpoint,
		config:    config,
		modifiers: NewODataMods(),
	}
}