Code Monkey home page Code Monkey logo

go-solr's Introduction

go-solr's People

Contributors

arrpee avatar djinn avatar ederfmartins avatar gadelkareem avatar keymastervn avatar nitsanfiverr avatar vanng822 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-solr's Issues

I want to use it in a Proxy environment

Request

Reason :
I want to use it in a Proxy environment

Make a request
connection.go
Line:16
var transport = http.Transport{}

Don't initialize with empty, just use
DefaultTransport
or
or add the following function
func SetTransport(h http.Transport) {
transport = h
}

Example :
http.DefaultTransport = &http.Transport{ Proxy: http.ProxyURL(proxyUrl) }
I want to use defaultTransport and use it around like
Or
tr := &http.Transport{
ResponseHeaderTimeout: 30 * time.Second,
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 2 * time.Second,
}).DialContext,
MaxIdleConns: 0,
IdleConnTimeout: 30 * time.Second,
TLSHandshakeTimeout: 2 * time.Second, }),
Second, MaxIdleConnsPerHost: 100,
//DisableKeepAlives: false,
DisableKeepAlives: true,
}
solr.SetTransport(tr)

Please.

Refactoring: reduce number of response types

we should have 2 type of response for raw response from solr, one for select and other get method, this should have Status property for quick access and one for update/post which should contain Success to indicate if the operation was successfully.

Adding support for basic auth

Suggestion:

  1. Alter connection HTTPPost and HTTPGet so we can somehow pass login info
  2. Connection should contain login info
  3. Possibility to pass login info when create a new SolrInterface or set login info from SolrInterface

how to go about inserting []jsonDocs ( Update() returns success but solr logs show failures)

I already have json docs as string

following code snippet is used to construct a valid json string.

func StoreInSolr(sc *solr.SolrInterface, docs []string) (*solr.SolrUpdateResponse, error) {
	params := &url.Values{}
	params.Add("commit", "true")
	var lines []string
	for _, doc := range docs {
		if len(strings.TrimSpace(doc)) == 0 {
			continue
		}
		lines = append(lines, doc)
	}
	data := fmt.Sprintf("[%s]\n", strings.Join(lines, ","))
	fmt.Printf("data: %+v\n", data)
	resp, err := sc.Update(data, params)
	return resp, err
}
both resp and err indicate success:
&solr.SolrUpdateResponse{Success:true, Result:map[string]interface {}{"responseHeader":map[string]interface {}{"QTime":3, "status":0}}}, err: <nil>

but on solr debug logs i get

o.a.s.h.l.JsonLoader Can't have a value here. Unexpected STRING at [1]

This has to do with json string format but json is valid.

any pointers appreciated .

how about add solr stream export handler support

i want to add solr stream export support in project by adding an response parser base on binlog encode format,
i have make the test case code passed ,i want to commit a PR later ,is that OK?

logging

Good Job! How to get debug info for the raw query sent to solr?

Handle cancellations and graceful shutdowns using standard context.Context

Add support to pass standard context.Context to Search and other functions in order to handle cancellations and graceful shutdowns properly.

Sample use:

package main
import (
        "context"
	"github.com/vanng822/go-solr/solr"
	"fmt"
)

func main() {
  ctx := context.Background()

  si, _ := solr.NewSolrInterfaceWithCtx(ctx, "http://localhost:8983/solr", "collection1")

  query := solr.NewQuery()
  query.Q("*:*")

  s := si.SearchWithCtx(ctx, query)
  r, _ := s.Result(nil)

  fmt.Println(r.Results.Docs)
}

Provide methods to Query for most common search params

Interesting params:

.Sort(sortBy string)
.FilterQuery(fq string)
.FieldList(fl string)
.Geofilt(latitude float64, longitude float64, sfield string, distance float64)
.DefType(defType string)
.BoostFunctions(bf string)
.BoostQuery(bq string)
.QueryFields(qf string)

SolrInterface should support corename

This makes the configuration easier, solrUrl will be up to solr and applications can use it for both Select, Update and Core Admin. But for Update and Select we need core name. This is probably best a property of Connection but should be able to specify when creating a new SolrInterface. Can be interesting that corename can be switched as well.

Panic on interface convertion

interface conversion: interface {} is nil, not map[string]interface {}:
panic(0x2423640, 0xc0168b8930)
	C:/Go/src/runtime/panic.go:513 +0x1c7
github.com/vanng822/go-solr/solr.(*StandardResultParser).Parse(0x3410718, 0xc07f1360e0, 0x6, 0xc015d9cf38, 0xc07f1360e0)
	C:/Users/Margaryta/GoSrc/src/bitbucket.org/repustate/repustate-go/src/github.com/vanng822/go-solr/solr/parser.go:130 +0x6a5
github.com/vanng822/go-solr/solr.(*Search).Result(0xc032187710, 0x0, 0x0, 0x0, 0x1, 0xc04ed9c0b0)
	C:/Users/Margaryta/GoSrc/src/bitbucket.org/repustate/repustate-go/src/github.com/vanng822/go-solr/solr/search.go:72 +0xbe

Happens when Solr fails to load core to execute solr.Search , in such cases Solr instance returns error object like :

  "error":{
    "metadata":[
      "error-class","org.apache.solr.core.SolrCoreInitializationException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"SolrCore 'clientindices' is not available due to init failure: Could not load configuration from directory /var/solr/data/configsets/_default",
    "trace":"org.apache.solr.core.SolrCoreInitializationException: SolrCore 'clientindices' is not available due to init failure: Could not load configuration from directory /var/solr/data/configsets/_default\n\tat org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1593)\n\tat org.apache.solr.servlet.HttpSolrCall.init(HttpSolrCall.java:249)\n\tat .
...
org.apache.solr.servlet.HttpSolrCall.handleAdmin(HttpSolrCall.java:734)\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:496)\n\t... 36 more\n",
    "code":500}}

Spellcheck support

In my project, I have a requirement of adding spellcheck and suggestions for solr search. I would like to know whether you will be able to add these options to SolrResponse or do you plan to provide raw response support in your package?

Fetching result and build SelectResponse

Can be good to rethink if we can give an option for other to provide the Document type themself. Maybe document should be an interface with some basic setters and getters

Error for Delete function in solr.go

The following error is coming when message is being created in delete function in solr.go
Failed to evaluate expression - Message (type github.com/vanng822/go-solr/solr.M) is not a struct

  1. delete function is expecting a data of type map[string]interface{} and then this data is being used as interface{} value for message variable but an error is coming there

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.