first working version
This commit is contained in:
parent
18995db757
commit
de359ab415
47 changed files with 1016 additions and 2012 deletions
|
|
@ -51,15 +51,17 @@ func (i *Index) Close() error {
|
|||
return i.i.Close()
|
||||
}
|
||||
|
||||
func (i *Index) Add(id, text, docType string) error {
|
||||
doc, _ := i.i.Document(id)
|
||||
if doc != nil {
|
||||
err := i.Delete(id)
|
||||
if err != nil {
|
||||
return err
|
||||
func (i *Index) Add(text, docType string) (id string, err error) {
|
||||
id = newID()
|
||||
for {
|
||||
doc, _ := i.i.Document(id)
|
||||
if doc == nil {
|
||||
break
|
||||
}
|
||||
id = newID()
|
||||
}
|
||||
return i.i.Index(id, indexDocument{text, core.Now(), docType})
|
||||
err = i.i.Index(id, indexDocument{text, core.Now(), docType})
|
||||
return
|
||||
}
|
||||
|
||||
func (i *Index) Delete(id string) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue